R – Server.Transfer to internal virtual application

server.transfer

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.

Best Answer

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.