Asp.net MVC 4 subsequent operations for creating an area in a new project, mvcarea

Source: Internet
Author: User

Asp.net MVC 4 subsequent operations for creating an area in a new project, mvcarea

After creating an area in Asp.net MVC 4 in a new project, HomeController is often confused with the HomeController routing of the area. You need to manually set some places to prevent mvc from recognizing the default Routing Status.

Detailed steps:

1. Check whether AreaRegistration. RegisterAllAreas () has been automatically added to Global. asax and \ App_Start \ RouteConfig. cs. If it does not exist, go to step 2. Otherwise, go to step 2.

2. In \ App_Start \ RouteConfig. cs, add AreaRegistration. RegisterAllAreas ();

Public static void RegisterRoutes (RouteCollection routes) {routes. ignoreRoute ("{resource }. axd/{* pathInfo} "); AreaRegistration. registerAllAreas (); routes. mapRoute (name: "Default", url: "{controller}/{action}/{id}", defaults: new {controller = "Home", action = "Index ", id = UrlParameter. optional}, namespaces: new [] {"tew.vcapplication. controllers "});}

3. In \ App_Start \ RouteConfig. cs, check whether the default Controller namespace is explicitly specified in routes. MapRoute.

Namespaces: new [] {"tew.vcapplication. Controllers "}

 

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.