2

I tried to change my default route template:

  • {controller=Home}/{action=About}/{id?}

But when I start my project (without any url path - just: http://localhost:49406/) it always loads the Index instead of the About. I have no other routes and I don't use attribute routing at all.

I also tried to change the default controller:

  • {controller=Main}/{action=Index}/{id?}

It loads the HomeController's Index instead of the MainController's Index.

Is it a bug or I forgot something?

3
  • Please share the actual source code Commented Feb 19, 2017 at 9:18
  • Is just the default ASP.NET Core Web Application (.NET Core) > Web Application project within Visual Studio 2017 Community. I didn't change anything except the route template in the Startup.cs. Which part of this large project template should I share? Commented Feb 19, 2017 at 9:39
  • Yes, can you please share route template code block from Startup and MainController? Commented Feb 19, 2017 at 10:03

1 Answer 1

1

If you are not using any attribute routing at all the problem should come from your Startup.cs file.

Make sure that you are calling app.UseMvc()only and not app.UseMvcWithDefaultRoute() in Configure method.

Sign up to request clarification or add additional context in comments.

2 Comments

There was an app.UseMvcWithDefaultRoute() line far above the the app.UseMvc() part. Thanks!
I am glad I could help you.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.