MVC 6 - Areas Routing is not redirecting to the configured page

风格不统一 提交于 2019-12-12 03:36:11

问题


I am working on "Microsoft.AspNetCore.Mvc": "1.1.2"

My project folder structure is as below

Code in startup.cs is below

When I run my project I am not redirected to the index page. It shows 404 Error. Am I missing any setting?


回答1:


Your url should have this pattern (due to your routes configuration):

http://localhost:your_port_number/area_name

When you run your application your url pattern is:

http://localhost:your_port_number

There is no area name in the url.

You should specify the area Admin in url, because you don't have default area and you get 404 Not Found, so your url should be like this:

http://localhost:your_port_number/Admin

OR

You can set default value for Area in app.UseMvc():

routes.MapRoute("adminRoute", "{area=Admin}/{controller=Admin}/{action=Index}/{id?}");

Now by default you call endpoint in area Admin with controller name Admin and action name Index.



来源:https://stackoverflow.com/questions/43225917/mvc-6-areas-routing-is-not-redirecting-to-the-configured-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!