Monday, July 29, 2013

Restricting MVC to Particular HTTP Verbs

[HttpGet]
        public ActionResult HerbyList()

        {

This is a perfect place to use Fiddler's composer - to change a regular page from a get to a post to test

also the older syntax:

[AcceptVerbs(HttpVerbs.Post)] 


an important use for this is one view for a get with default info and the same view for post to get the updated values  - example:

    [HttpGet]
        public ActionResult Update()
        {
            BookModel bm = new BookModel();
            bm.Author = "default";
            bm.Title = "default";

            return View(bm);
        }

        [HttpPost]
        public ActionResult Update(BookModel b)
        {
            return View(b);
        }



No comments:

Post a Comment