Question

How to run asp.net application without exposing the virtual directory in the URL. Like stackoverflow.com does?

Usually when you deploy your ASP.NET MVC application, you create a virtual directory on IIS and point users to the virtual directory. E.g. http://MyDomain.com/MyApp. However, StackOverflow appears without the virtual directory being exposed in the URL. How is this done? URL rewriting or other configuration techniques ?

Was it helpful?

Solution

You do not have to create a virtual directory, you can create an entire new site in IIS. From IIS manager, right click the sites folder listed under your server (IIS 7 or higher. Also available in IIS6 but views/click locations are different). Then select New Website. This brings up the following window in which you can specify the location for the website content, host header information (what domain name to respond to), port information (eg 80), app pool, etc.

enter image description here

By doing this, you can host multiple domains on a single IIS server. Note that if they are all sharing port 80, you have to specify a host name so that IIS knows how to handle multiple sites on a single port. If you do not specify a host name, only one of the websites will be active, the rest will be in a stop state.

OTHER TIPS

You don't have to create a virtual directory. There's a "Default Site", which will load directly under the domain. I can't speak for StackOverflow, but given that they're probably load-balancing with multiple servers already, it's highly unlikely that they're running anything but this site on the web server.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top