Question

I'm messing around with the cheapest .NET Arvixe server for learning purposes and try to install an application (Umbraco in this case) in a particular way.

Arvixe count's subdomains as websites, which means I'm currently limited to 6 of them. With some clever URL Rewrite trickery, I managed to setup the following structure.

FTP-folder:
> mydomain.com
>> wwwroot
>> subdomains
>>> subdomain1
>>> subdomain2
>>> etc.

wwwroot is the main website, under which I added Virtual Directories for each subdomain. So if in the browser you would go to http://www.mydomain.com/subdomain1, you'll end up seeing whatever app is installed under subdomains/subdomain1.

After applying some URL Rewrite, I can go to http://subdomain1.mydomain.com, and it will show me the same content as if I would go to http://www.mydomain.com/subdomain1

Now this is where the problem I'm experiencing begins.

Whenever in code I would do a relative path (eg. ~/Blog/Test/123.aspx), it will resolve to http://subdomain1.mydomain.com/subdomain1/Blog/Test/123.aspx. This all still works, as the everything is still under a single website, I just don't want the /subdomain1/ part in the URL. If I manually remove the /subdomain1/ part, the page also render fine due to my rewrite rules.

After some searching I found out that internally, whenever code has to resolve a ~/-url, it will use HttpRuntime.AppDomainAppVirtualPath for that.

How can I trick ASP.NET into thinking it's hosting under the Virtual App Path of '/' rather than '/subdomain1/'?

I have tried a few things which do not work (or I just did it wrong): - Thread.GetDomain().SetData(".appVPath", "/"); - Make a VirtualPathProvider

In all cases, it will throw exceptions.

Is hosting under it's own website really the only solution (which means I have to upgrade the account)?

Was it helpful?

Solution

I tried all kinds of hacks by means of Reflection, so it's certainly not possible by normal means. In the end I got as far as confusing IIS, as the ApplicationRoot wasn't overwritten on all locations. So I gave up, it's not possible.

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