Using System;
Using System.Collections.Generic;
Using System.Linq;
Using System.Net.Http;
Using System.Text;
Using System.Web;
Using System.Web.Http;
Using SYSTEM.WEB.MVC;
Namespace Webapi.controllers
{
public class Homecontroller:apicontroller
{
Public list<usermodel> allmodelist = new List<usermodel> ()
{
New Usermodel () {id=1,username= "Zhang", password= "123"},
New Usermodel () {id=2,username= "Lishi", password= "123456"},
New Usermodel () {id=3,username= "Wang", password= "1234567"}
};
[System.Web.Http.HttpPost]
Public Httpresponsemessage GetAll ()
{
return allModeList.Count.ToString ();
Httpresponsemessage hr = new Httpresponsemessage ();
String name = "Yangliu";
list<dynamic> list = new List<dynamic> {new {name = "Zhang San", age = +}, new {name = "John Doe", age = 15}};
hr. Content = new Stringcontent (Newtonsoft.Json.JsonConvert.SerializeObject (allmodelist), Encoding.UTF8, "application/ JSON ");
return HR;
}
}
public class Usermodel
{
public int Id {get; set;}
public string UserName {get; set;}
public string PassWord {get; set;}
}
}
Initial knowledge of ASP. NET WebApi