This blog is about the dotnet.all types of codes,news about dotnet including asp.net,vb.net,c# and know about new dotnet technology.programing in asp.net,vb.net,c#, ajax, AJAX tech support for .net and discuss the new technology in dotnet.ncluding asp.net,vb.net,c# and know about new dotnet technology.programing in asp.net,vb.net,c#, ajax, AJAX tech support for .net and discuss the new technology in dotnet.asp.net programming,dot net programming,dotnet programs,dotnet source code,source code.

Free Hosting

Free Hosting

Sunday, November 2, 2008

DOTNET Code to Hosting multiple websites on one domain

Have you ever wondered how you could host multiple websites on one domain hosting service.
Well it is simple with this asp.net script i achieve just that. This is very usefull for people like us who dont want to invest a lot of money for domain hosting.

CODE:
///// add this in the asp.net page. load even as shown below
private void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack)
{
string url = Request.Url.ToString().ToLower();
string domain;
// get the domain name
if ( url.StartsWith( "http://" ) )
url = url.Substring( 7 );
int x = url.IndexOf( '/' );
if ( x > 0 )
domain = url.Substring( 0, x );
else domain = url;

// redirect based on domain
switch( domain )
{
case "www.domain1.com":
case "domain2.com":
Response.Redirect( "home.aspx", true );
return;

case "www.domain2.com":
case "domain2.com":
Response.Redirect( "index.html", true );
return;

}

Server.Transfer("index.aspx");
}
}

0 comments:

dotnet(.Net) Project Source code Downloads and Tutorials

Email Subscrption



Enter your email address:

Delivered by FeedBurner

Feedburner Count

Blog Archive

Unique Visitor

Design by araba-cı | MoneyGenerator Blogger Template by GosuBlogger