MVC Multi-level areas

Source: Internet
Author: User

MVC can only be created under the areas name folder, "area" (with the accompanying Controller,view,model).  However, there are times when you want to create a module folder under the areas, which is created in the section below the module folder. Can not be implemented in direct operation. Can do this

1. Create a module folder under areas, such as aboutlinq

2. Add a region under areas, such as LINQ

3. Cut the area LINQ to Aboutlinq

4. After modification, the CS file below the LINQ area.

Using SYSTEM.WEB.MVC;


Modified here 1
Namespace MyTest.Areas.AboutLinq.LINQ
{
public class Linqarearegistration:arearegistration
{
public override string AreaName
{
Get
{

Modified here 2
return "Aboutlinq/linq";
}
}

public override void Registerarea (AreaRegistrationContext context)
{
Context. MapRoute (

Modified here 3
"Aboutlinq_linq_default",

Modified here 4
"Aboutlinq/linq/{controller}/{action}/{id}",
New {action = "Index", id = urlparameter.optional}
);
}
}
}

5. Create a generated view below Aboutlinq, cut to LINQ below.

Http://localhost:1876/AboutLinq/LINQ/LinqSentence/Index will have access to the

MVC Multi-level areas

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.