MVC4 Model Controllerdescriptor

Source: Internet
Author: User

1. Description of Controllerdescriptor

The Controller's action method has some of the following characteristics:

1.1 Actionnameattribute attribute he inherits from System.Web.Mvc.ActionNameSelectorAttribute abstract class

Actionnameselectorattribute uses its abstract method isvalidname to determine whether the specified action name matches the target action method.

The following code snippet:

After adding the Actionnameattribute attribute, the Access action will match the actionname instead of the actionnames note that there is a "s" Behind the Aciton method

        [ActionName ("actionname")]          Public actionresult actionnames ()        {            return Json ("", Jsonrequestbehavior.allowget);        }

Actionnameselectorattribute differs from Actionmethodselectorattribute: both have action filtering, which is for the action name and whether it matches the request

There are 7 types of 1.2 Actionmethodselectorattribute (:

Httpget,httppost,httpput,httpdelete,httphead,httpoption,httppatch. The following code snippet:

[HttpGet]          Public actionresult HttpMethod ()        {            return Content ("");        }

1.3 Acceptverbsattribute characteristics, It differs from Actionmethodselectorattribute in that it can match multiple HTTP methods at the same time, as in the following code snippet:

This makes it possible to use a post or GET request at the same time, and if you remove get, you can only use the POST request.

   [Acceptverbs (Httpverbs.post |  Httpverbs.get)]       public  actionresult acceptverbs ()    {     return Json (" ", Jsonrequestbehavior.allowget);    }

1.4 Nonactionattribute Features:

The Action method that sets the Nonactionattribute attribute is always excluded from the candidate range when requested, as in the following code snippet

When the Nonactionattribute attribute is added, the access will appear HTTP 404. Error

[nonaction]    Public actionresult nonactions ()  {    return Content ("nonactionattribute");   }

2.ActionDescriptor

3.ParameterDescriptor

MVC4 Model Controllerdescriptor

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.