asp.net mvc url.action () usage detailed

Source: Internet
Author: User
Tags anonymous

The Url.action () method is also a common method in ASP.net mvc, which has 8 overloaded methods, and the use of each overload method is shown in the following table.

Url.action overloaded List
name Description Sample
Action (String) Generates the fully qualified URL of an action method using the specified action name @Url. Action ("Action1")
Action (String, Object) Generates the fully qualified URL of an action method using the specified action name and route value @Url. Action ("Action1", new {id=1}), note: The second parameter is type object so you can directly new an anonymous object, and note the comparison with the following overloaded methods
Action (String, String) Generates the fully qualified URL of an action method using the specified action name and controller name @Url. Action ("Action1", "Controller1")
Action (String, RouteValueDictionary) Generates the fully qualified URL of an action method for the specified action name and route value @Url. Action ("Action1", new RouteValueDictionary {{"id", 1}}), note: The second parameter type is routevaluedictionary type so it can't just be a simple new one anonymous object
Action (String, String, Object) Generates the fully qualified URL of an action method using the specified action name, controller name, and route value @Url. Action ("Action1", "Controller1", new {id=1})
Action (String, String, RouteValueDictionary) Generates the fully qualified URL of an action method using the specified action name, controller name, and route value @Url. Action ("Action1", "Controller1", new RouteValueDictionary {{"id", 1}})
Action (String, String, Object, String) The fully qualified URL that generates the action method using the specified action name, controller name, route value, and protocol to use @Url. Action ("Action1", "Controller1", new {id=1}, "http or https")
Action (String, String, RouteValueDictionary, String, String) Generates the fully qualified URL of the action method using the specified action name, controller name, route value, protocol to be used, and host name @Url. Action ("Action1", "Controller1", new RouteValueDictionary {{"id", 1}}, "http or https", "www.baidu.com"), Note: The last parameter is the host name that is the domain name

Related Article

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.