如何改写WebApi部分默认规则
2个回答
2017-05-19
展开全部
1、不再限制控制器必须以Controller结尾,其实这个并不是必须,只是被限制着确实不太舒服。
2、所有方法可以响应所有的请求方法,如果存在方法名相同的方法,那么才需要特性来区分。
3、Action中的参数优先从Url中获取,再从Body中获取,从Body中获取的时候,优先假设Body中的数据是表单参数,若不是则将Body中的数据当作json或xml数据进行获取。
2、所有方法可以响应所有的请求方法,如果存在方法名相同的方法,那么才需要特性来区分。
3、Action中的参数优先从Url中获取,再从Body中获取,从Body中获取的时候,优先假设Body中的数据是表单参数,若不是则将Body中的数据当作json或xml数据进行获取。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
string;= 0)
{
lock (_desriptors)
{
if (_desriptors;
IDictionarylt.IsDynamic);
public ControllerSelector(HttpConfiguration config)
{
_config = config.Where(x =.Get(; _desriptors = new Dictionarylt;
}
var descriptors = new Dictionarylt;
foreach (var ass in assemblies)
{
controllerTypes对控制器的限制
public class ControllerSelector .GetRouteData();)).Web;
var controllerTypes = new Listlt.Values;
}
}
}
}
}
public IDictionarylt;
return _desriptors;typeof(ApiController);(), HttpControllerDescriptor;= 0)
{
var assemblies = AppDomain.Controllers;string.Count lt.GetExportedTypes();
foreach (var controllerType in controllerTypes)
{
var descriptor = new HttpControllerDescriptor(_config, HttpControllerDescriptor;controller.GetAssemblies();
}
void InitControllers()
{
if (_desriptors!x.Count lt.IsNullOrWhiteSpace(controllerName))
{
throw new ArgumentException(string.Where(x =, HttpControllerDescriptor, controllerType)!x;(StringComparer, HttpControllerDescriptor;
if (string.Http;
_desriptors.HttpRequestMessage request)
{
InitControllers(), controllerType.HttpControllerDescriptor SelectController(System;().OrdinalIgnoreCase).Net.CurrentDomain.Name, descriptor);)); ;string.GlobalAssemblyCache .Add(descriptor;
}
public System.ControllerName;Type.AddRange(ass;没有在路由信息中找到controller.IsAssignableFrom(x)));string: IHttpControllerSelector
{
HttpConfiguration _config.Http;
var controllerName = Convert;
var routeData = request.ToString(routeData.Format(; GetControllerMapping()
{
InitControllers()
{
lock (_desriptors)
{
if (_desriptors;
IDictionarylt.IsDynamic);
public ControllerSelector(HttpConfiguration config)
{
_config = config.Where(x =.Get(; _desriptors = new Dictionarylt;
}
var descriptors = new Dictionarylt;
foreach (var ass in assemblies)
{
controllerTypes对控制器的限制
public class ControllerSelector .GetRouteData();)).Web;
var controllerTypes = new Listlt.Values;
}
}
}
}
}
public IDictionarylt;
return _desriptors;typeof(ApiController);(), HttpControllerDescriptor;= 0)
{
var assemblies = AppDomain.Controllers;string.Count lt.GetExportedTypes();
foreach (var controllerType in controllerTypes)
{
var descriptor = new HttpControllerDescriptor(_config, HttpControllerDescriptor;controller.GetAssemblies();
}
void InitControllers()
{
if (_desriptors!x.Count lt.IsNullOrWhiteSpace(controllerName))
{
throw new ArgumentException(string.Where(x =, HttpControllerDescriptor, controllerType)!x;(StringComparer, HttpControllerDescriptor;
if (string.Http;
_desriptors.HttpRequestMessage request)
{
InitControllers(), controllerType.HttpControllerDescriptor SelectController(System;().OrdinalIgnoreCase).Net.CurrentDomain.Name, descriptor);)); ;string.GlobalAssemblyCache .Add(descriptor;
}
public System.ControllerName;Type.AddRange(ass;没有在路由信息中找到controller.IsAssignableFrom(x)));string: IHttpControllerSelector
{
HttpConfiguration _config.Http;
var controllerName = Convert;
var routeData = request.ToString(routeData.Format(; GetControllerMapping()
{
InitControllers()
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询