Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get rid of Home in ASP.Net MVC?

I know this site is written using ASP.Net MVC and I do not see "/Home" in the url. This proves to me that it can be done. What special route and do I need?

like image 399
pelleg Avatar asked Aug 19 '08 01:08

pelleg


People also ask

How to remove cookies in MVC?

Cookies cannot be deleted or removed, it can be made to expire by setting its Expiry Date to a Past Date in ASP.Net MVC Razor.

How to remove cookies in ASP net?

Add(new HttpCookie("ASP. NET_SessionId", "")); This code example clears the session state from the server and sets the session state cookie to null. The null value effectively clears the cookie from the browser.

How do I delete a controller in Visual Studio?

Answers. Just delete the homecontroller. cs file, and the home directory in the views folder. As suggested you need to pick a a different default route.

What is home controller in MVC?

A controller determines what response to send back to a user when a user makes a browser request. A controller is just a class (for example, a Visual Basic or C# class). The sample ASP.NET MVC application includes a controller named HomeController. cs located in the Controllers folder.


2 Answers

Just change "Home" to an empty string.

routes.MapRoute(
    "Home",
    "",
    new { action = Index, controller = Home }
);
like image 172
Nick Berardi Avatar answered Sep 19 '22 13:09

Nick Berardi


If you're running on IIS 7, you can simply delete the Default.aspx file that comes with ASP.NET MVC (assuming you're running on Preview 3 or higher). That file was needed due to an issue with Cassini that was fixed in .NET 3.5 SP1. For more details check out:

http://haacked.com/archive/2008/04/10/upcoming-changes-in-routing.aspx and http://haacked.com/archive/2008/05/12/sp1-beta-and-its-effect-on-mvc.aspx

like image 34
Haacked Avatar answered Sep 16 '22 13:09

Haacked