0

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

My project folder structure is as below

enter image description here

Code in startup.cs is below

enter image description here

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

Sachin Pakale
  • 292
  • 2
  • 4
  • 19
  • I find this answer resolved, do you try [this](http://stackoverflow.com/questions/36535511/how-to-use-an-area-in-asp-net-core)? – An Phạm Apr 05 '17 at 10:08

1 Answers1

2

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.

Roman
  • 11,966
  • 10
  • 38
  • 47
  • Setting Area name in app.UseMVC() worked for me. Now I my page is redirecting to Index.cshtml as expected. I also have removed [Area("Admin")] on my controller. I searched a lot about my issue but never got Area name in MapRoute. Now I wonder how does it work for others without specifying Area name in MapRoute. – Sachin Pakale Apr 05 '17 at 10:51
  • Yes :) Thank you so much! – Sachin Pakale Apr 05 '17 at 10:53