Any way to handle Put and Delete verbs in ASP.Net

2019-04-01 00:34发布

just wondering if anyone knows of a truly restful Put/delete implementation asp.net mvc preview 5 preferably.

6条回答
SAY GOODBYE
2楼-- · 2019-04-01 00:39

Rails uses a "method" parameter in the form and then fakes it, but calls the appropriate method if you designate it.
I understand most clients won't support restful stack, but can asp.net mvc, auto-negotiate these verbs and place them in the appropriately deemed actions?

查看更多
手持菜刀,她持情操
3楼-- · 2019-04-01 00:40

I don't know of one off the top of my head, but you might look into the way that Rails handles it if you don't find anything else, and try porting it over. Rails utilizes POST, GET, PUT, and DELETE, but it apparently has to do some fakery for PUT. Could be worth looking into if you come up dry here.

查看更多
Rolldiameter
4楼-- · 2019-04-01 00:46

Check out the mvccontrib project at http://www.mvccontrib.org. In the source code a restful implementation has been added and it is current up to Preview 5. Check out the source code here - http://mvccontrib.googlecode.com/svn/trunk/src/MVCContrib/SimplyRestful

查看更多
啃猪蹄的小仙女
5楼-- · 2019-04-01 00:46

I've been covering this in my blog http://shouldersofgiants.co.uk/blog/ where I'm looking at an entire RESTful web service based on ASP.Net and MVC

查看更多
Viruses.
6楼-- · 2019-04-01 00:52

With MVC Beta, u can now use an HttpVerbs enumeration.

here's an example...

[AcceptVerbs(HttpVerbs.Get)]
public ActionResult Index()
{ ... }

[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Update()
{ ... }

[AcceptVerbs(HttpVerbs.Delete)]
public ActionResult Delete()
{ ... }

you get the idea.

hth :)

查看更多
We Are One
7楼-- · 2019-04-01 00:54

I think that the new AcceptVerbsAttribute in preview 5 should be capable of directing any type of request to a designated action. Marking a method like below in theory allows handling of all verbs but I haven't explicitly tested put or delete.

[AcceptVerbs("delete")]
public object DoDeleteAction()
查看更多
登录 后发表回答