views:

286

answers:

2

My question is how to manage several virtual applications, located at the same host

firstdomain.com is redirected to firstdomain.com/1 seconddomain.com is redirected to seconddomain.com/2 and so on... each new domain must be located at different folder, and for now it is working fine. But it causes some inconvenient, for example seconddomain.com/1 is showing firstdomain.com web site.

i'm trying to create something like dispatch at root directory "/" to transfer necesary domain with Server.Transfer("").

but it is not working like I thought:

Server.Transfer("/" + folder + "");

causes this error:

Server Error in '/' Application. Error executing child request for /web_folder.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: Error executing child request for /web_folder.

Server.Execute("/" + folder + "");

causes error too:

Error executing child request for /web_folder.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: Error executing child request for /web_folder.

both applications works fine accessed by its specified url.

and also there is a problem with two applications, if I use HttpModules from root web.config, it causes compilation error inside virtual application. It may be passed, if I add reference to same project in virutal site.

Any suggestions ?

i think there must be any solution, many people need to redirect any subdomain to a subfolder without Redirect, to keep the original URL dsplay

thanks.

+1  A: 

You cannot Server.Transfer to an application that is hosted to a different virtual directory in IIS than the one that's performing the request.

Darin Dimitrov
what is the best solution?it is possible to avoid .Redirect("/2") ?
Гносис
I think thats because Server.Transfer keeps the original page in memory unlike Response.Redirect and each web app in ISS has its own separate memory domain
A9S6
Can't you do these redirects at DNS level?
Darin Dimitrov
i only have virtual hosting, I dont think i have right on DNS server. I can only add/remove subdomains.
Гносис
A: 

Server.Transfer can only happen for single HttpContext. Each virtual directory or app has its own HttpContext object and they know not that co-exists! so you cannot do that.

this. __curious_geek
good argument, thanks
Гносис