using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using System.Web.Http.Description;
namespace WebSocket.Api
{
/// <summary>
/// List文章列表
/// </summary>
public class ListController : ApiController
{
// GET api/<controller>
/// <summary>
/// Listjson方法
/// </summary>
/// <returns></returns>
[AcceptVerbs("GET", "POST")]
[Route("API/List/Listjson/")]
[ResponseType(typeof(ReturnResult))]
public HttpResponseMessage Listjson()
{
ReturnResult result = new ReturnResult() {code = 0,msg="成功"};
result.data = JsonConvert.SerializeObject(new string[] { "value1", "value2" });
string json = JsonConvert.SerializeObject(result);
return new HttpResponseMessage { Content = new StringContent(json, System.Text.Encoding.UTF8, "application/json") };
}
}
internal class ReturnResult
{
/// <summary>
///数据状态一切正常的状态码 0:成功,1:失败
/// </summary>
public int code { get; set; } = 1;
/// <summary>
/// 状态信息
/// </summary>
public String msg { get; set; } = "失败";
/// <summary>
/// 数据详情
/// </summary>
public string data { get; set; }
/// <summary>
/// 数据总条数
/// </summary>
public int count { get; set; } = 0;
}
}