I need to show my View on the main page. Suppose that I have an application called “Sample”. When a user comes to sample.com it will go to the sample.com/Home/Index. Is there any way/method to show the view in sample.com itself as we do in pure HTML Pages? Even though I’ve done several google-search I ended up in misleading content.
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
You have to set RouteConfig:
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
Result:
http://localhost:51225/Home/Index/1 => Index.html http://localhost:51225/Home/Index/ => Index.html http://localhost:51225/Home/ => Index.html http://localhost:51225/ => Index.html http://sample.com/Home/Index/1 => Index.html http://sample.com/Home/Index/ => Index.html http://sample.com/Home/ => Index.html http://sample.com/ => Index.html
You can learn more at:
https://www.tutorialsteacher.com/mvc/routing-in-mvc
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0