zoukankan      html  css  js  c++  java
  • 初识Asp.Net WebApi

    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 = "张三", age = 17 }, new { name = "李四", 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; }
    }
    }

  • 相关阅读:
    Codeforces Round #436 (Div. 2)
    【bzoj1090】 [SCOI2003]字符串折叠
    【并查集】食物链(带权并查集)
    【图论】二分图
    【图论】关押罪犯
    关于图论的若干巴拉巴拉
    一系列的入门and一堆吐槽
    【分块】八
    9-30刷题记录
    bzoj5055
  • 原文地址:https://www.cnblogs.com/momjs/p/8360100.html
Copyright © 2011-2022 走看看