OpenAuth.Net/OpenAuth.Mvc/Models/JobjectModelBinder.cs
yubaolee 56d5ea0e8a 更改PDM文件
删除为用户分配可见机构(本身有机构功能)
删除为角色分配机构(本身有机构多对多功能)
2016-09-04 23:34:16 +08:00

25 lines
755 B
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System.Web.Mvc;
using Newtonsoft.Json.Linq;
namespace OpenAuth.Mvc.Models
{
/// <summary>
/// 将前端传来的FormData数据转为Jobject类型
/// 注前端如果是application/json可以直接转JOjbect
/// </summary>
public class JobjectModelBinder :IModelBinder
{
public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
{
//todo:需要判断前端是否是FormData
var obj = new JObject();
var request = controllerContext.HttpContext.Request;
foreach (var key in request.Form.AllKeys)
{
obj[key] = request.Form[key];
}
return obj;
}
}
}