I currently have 2 MVC websites, both built originally as ASP.NET forms applications in Visual Studio 2013 with .NET framework version 4.5. They were later migrated to an MVC platform in Visual Studio 2013, without changing the framework version. We are
currently trying to upgrade both projects to the latest version of .NET (4.6) and switch to Visual Studio 2017 for development, testing, and deployment of both applications.
The conversion of the projects to VS2017 encountered one issue which seems rooted in a fundamental change to the ASP.NET MVC framework that was implemented with the release of VS2017. The problem manifested itself in one of our applications which uses 2
separate MVC Areas in its routing scheme. We do not, for the most part, use the auto-generated folders for Controllers, Models, and Views that are created with a new MVC project template. Rather, there is a folder for 'Areas' with 2 subfolders. These are a
standard 'Home' area/folder, with its main folder and subfolders for Controllers, Models, and Views which are accessed by the routing engine.
We also have an 'Applications' area/folder (applications refers to applying to be part of our organization, not web applications). This has the same sub-structure as the 'Home' folder with Controllers, Models, and Views separated into sub-folders. In the
current working version of our code, either area can be accessed using a parameter indicating the correct area (e.g. '….{new Area="Applications"}' or the method, controller, and area (e.g. href="@Url.Action("Index", "Teacher", new { area
= "Applications" })").
While the 'Home' area runs as expected in the new VS2017 environment, it seems that the new routing engine is unable to recognize and locate the controllers and views in the 'Applications' area. It returns a 404 error for all methods / views in the 'Applications'
area. Any pointers as to what changed need to be done to make the original project compatible with VS-2017, as I am getting a 404 error when trying to access views from the second 'area' in the project when running it.
None
0 Points
1 Post
Migrating from VS 2013 to VS 2017 MVC routing issues
Jun 22, 2017 03:33 PM|HB_123|LINK
I currently have 2 MVC websites, both built originally as ASP.NET forms applications in Visual Studio 2013 with .NET framework version 4.5. They were later migrated to an MVC platform in Visual Studio 2013, without changing the framework version. We are currently trying to upgrade both projects to the latest version of .NET (4.6) and switch to Visual Studio 2017 for development, testing, and deployment of both applications.
The conversion of the projects to VS2017 encountered one issue which seems rooted in a fundamental change to the ASP.NET MVC framework that was implemented with the release of VS2017. The problem manifested itself in one of our applications which uses 2 separate MVC Areas in its routing scheme. We do not, for the most part, use the auto-generated folders for Controllers, Models, and Views that are created with a new MVC project template. Rather, there is a folder for 'Areas' with 2 subfolders. These are a standard 'Home' area/folder, with its main folder and subfolders for Controllers, Models, and Views which are accessed by the routing engine.
We also have an 'Applications' area/folder (applications refers to applying to be part of our organization, not web applications). This has the same sub-structure as the 'Home' folder with Controllers, Models, and Views separated into sub-folders. In the current working version of our code, either area can be accessed using a parameter indicating the correct area (e.g. '….
{new Area="Applications"}
' or the method, controller, and area (e.g.href="@Url.Action("Index", "Teacher", new { area = "Applications" })")
.While the 'Home' area runs as expected in the new VS2017 environment, it seems that the new routing engine is unable to recognize and locate the controllers and views in the 'Applications' area. It returns a 404 error for all methods / views in the 'Applications' area. Any pointers as to what changed need to be done to make the original project compatible with VS-2017, as I am getting a 404 error when trying to access views from the second 'area' in the project when running it.
Participant
1380 Points
608 Posts
Re: Migrating from VS 2013 to VS 2017 MVC routing issues
Jun 22, 2017 10:20 PM|JBetancourt|LINK
in your RegisterRoutes method call register areas:
more details on:
https://msdn.microsoft.com/en-us/library/ee671793(v=vs.98).aspx
Please remember to click "Mark as Answer" the responsES that resolved your issue.
Member
520 Points
286 Posts
Re: Migrating from VS 2013 to VS 2017 MVC routing issues
Jun 23, 2017 09:01 AM|EvenMa|LINK
Hi HB_123,
According to your description, it seems like there had same controller name in different areas.
I suggest you could add the namespace when register the area, see the following code:
If you have any other questions, please feel free to contact me any time.
Best Regards
Even