The only place on the entire internet I could find an explanation is on MSDN:
Specifies an alternative path for the application root URL. Use this option if the Web application root is not the root of your project.
From here I understood that "application root" is the path that retrieves when using tilde in ASP.NET. So I would expect that if I go to project's properties - Web - "Override application root" and specify another url then the tilde would map to that url.
But it doesn't. For example my web is on a virtual directory - http://localhost/WebApplication1
and on "Override application root" I try to specify http://localhost/WebApplication2
or http://localhost
or http://WebApplication2
(which all exist on my local IIS). Now when I write
Response.Redirect("~/test2/login");
I expect it to redirect me to http://localhost/WebApplication2/test2/login
.
But instead it redirects me to http://localhost/WebApplication1/test2/login
as if I didn't override the "application root".
So what does this feature really suppose to do? Or maybe it's not working because I'm missing something and didn't define it properly?
Override application root URL doesn't change where the Application root is within your application. It changes the URL used to reach the application root. Because IIS does some hostname verification it's used to specify if you want to reach your application by a means other than
localhost:[PORT]
.For instance, if you override it to
www.myapp.com
you can then reach your application by adding this to your hosts file:This might be especially useful if you're making your application available to a remote device (a virtual machine on your computer, or a mobile device on your network) because they would be unable to navigate to
localhost
as the application address.