如何改写WebApi部分默认规则
1个回答
展开全部
namespace Xinchen.SOA.Server
{
public class Startup
{
public void Configuration(IAppBuilder appBuilder)
{
HttpConfiguration config = new HttpConfiguration();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "{controller}/{action}"
);
config.Services.Add(typeof(ValueProviderFactory), new MyValueProviderFactory());//自定义参数查找,实现第三个目标
config.Services.Replace(typeof(IHttpControllerSelector), new ControllerSelector(config));//自定义控制器查找,实现第一个目标
config.Services.Replace(typeof(IHttpActionSelector), new HttpActionSelector());//自定义Action查找,实现第二个目标
appBuilder.UseWebApi(config);
{
public class Startup
{
public void Configuration(IAppBuilder appBuilder)
{
HttpConfiguration config = new HttpConfiguration();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "{controller}/{action}"
);
config.Services.Add(typeof(ValueProviderFactory), new MyValueProviderFactory());//自定义参数查找,实现第三个目标
config.Services.Replace(typeof(IHttpControllerSelector), new ControllerSelector(config));//自定义控制器查找,实现第一个目标
config.Services.Replace(typeof(IHttpActionSelector), new HttpActionSelector());//自定义Action查找,实现第二个目标
appBuilder.UseWebApi(config);
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询