Generate Area URL link

Source: Internet
Author: User
Tags actionlink

The URL link for area can be divided into three cases: the first is to generate a link to the current area in the current area, and the second is to generate a link to another area, and the third is to generate a link to the root in an area. Here are the three ways to generate a link, using a route definition that is system default.

If you want to generate a URL link for the current area in area, just use the following method:

@Html. ActionLink ("Click Me", "about")

It generates the following HTML code based on the current area and controller:

<a href= "/admin/home/about" >click me</a>

If you want to generate a URL link for another area, you need to use a variable named area in the anonymous parameter of the Html.ActionLink method to specify the area name to generate the link, as follows:


It will find the definition of the route based on the area specified, assuming that the corresponding route is defined in the support area, then it will generate the following link:

<a href= "/support/home/index" >click me to go to another area</a>

If you want to generate a link to a controller in the root directory in the current area, simply place the area variable into an empty string, as follows:

@Html. ActionLink ("Click me to go to top-level part", "Index", new {area = "}")

It will generate the following HTML link:

<a href= "/home/index" >click me to go to top-level part</a>

Generate Area URL link

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.