我如何使用ASP.NET MVC的路由功能处理下面的uri:
http://localhost/users/{username}/bookmarks/ - GET http://localhost/users/{username}/bookmark/{bookmarkid} - PUT
其中列出了{username}中用户的书签.
谢谢
您可以在action方法上使用[AcceptVerbs]属性
public class BookmarksController : Controller { [AcceptVerbs(HttpVerbs.Get)] public void Bookmarks(string user) { //add your bookmark } [AcceptVerbs(HttpVerbs.Post)] public void Bookmarks(string user, int? id) { //add your bookmark } }