初始化
This commit is contained in:
36
Face.Web/API/CommonController.cs
Normal file
36
Face.Web/API/CommonController.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using Face.Domain.ViewModels;
|
||||
using Face.Services.Cache;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web.Http;
|
||||
|
||||
namespace Face.Web.API
|
||||
{
|
||||
public class CommonController : ApiController
|
||||
{
|
||||
[HttpGet]
|
||||
public HttpResponseMessage GetIP()
|
||||
{
|
||||
ReturnResult<object> result = new ReturnResult<object>
|
||||
{
|
||||
Status = 200,
|
||||
Data = System.Web.HttpContext.Current.Request.UserHostAddress
|
||||
};
|
||||
|
||||
//OBJ转化成JSON
|
||||
string json = JsonConvert.SerializeObject(result);
|
||||
|
||||
//返回json数
|
||||
return new HttpResponseMessage()
|
||||
{
|
||||
Content = new StringContent(json, Encoding.UTF8, "application/json"),
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user