码迷,mamicode.com
首页 > Windows程序 > 详细

asp.net web api使用默认路由 put delete动作在IIS下受限

时间:2014-12-18 12:02:14      阅读:176      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   ar   io   color   os   使用   sp   

asp.net web api使用默认路由

1. put、delete动作在IIS中受限(可通过remove WebDAV,方法见上一篇

2.每个controller可写action有限,在单个业务操作较多的情况下需要建立多个controller


使用新路由,仅使用Get、Post动作

protected void Application_Start(object sender, EventArgs e) {     
var config = GlobalConfiguration.Configuration;     
var routes = config.Routes;     
routes.MapHttpRoute(         
"DefaultHttpRoute",         
"api/{controller}/{action}/{id}",         
new { id = RouteParameter.Optional }     
); 
}

public class TestController : ApiController {     
[HttpGet]     
public string[] List() {         
return new string[] {"a","b","c" };     
}     

[HttpGet] 
[HttpPost]    
public string[] Detail(string id) {         
return id;     
} 
}


asp.net web api使用默认路由 put delete动作在IIS下受限

标签:style   blog   http   ar   io   color   os   使用   sp   

原文地址:http://blog.csdn.net/ahywg/article/details/42002583

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!