Skip to content Skip to sidebar Skip to footer

What Is The Correct Way For Redirecting From The Domain Name Itself To A Page In A Directory?

I want anyone browsing for 'MyDomain.com' to see what's in 'MyDomain.com/Folder1/HomePage.aspx'. I tried adding a page with

Solution 1:

Meta will take some time because it will first come to client, and then it will be transferred to the new page since HTML executes in browser - not on server.

The fastest method if to place use Server.Transfer("~/Folder1/HomePage.aspx") on your Default.aspx page. This will be executed on server as compared to Response.Redirect which also throws content back to browser first, then transfers to new page.

But the drawback of using Server.Transfer("~/Folder1/HomePage.aspx") is that it will not change the URL of the browser. I mean even you will be sitting on "MyDomain.com/Folder1/HomePage.aspx" but browser will be showing you the URL of previous page.

I hope this answers your question. If yes, then mark it as "answered".

Solution 2:

What about trying something like this in the Default.aspx page load event?

Response.Status = "Redirecting"
Response.AddHeader("Location", "MyDomain.com/Folder1/HomePage.aspx")

Solution 3:

Response.Redirect

Seems to be the best way.

Post a Comment for "What Is The Correct Way For Redirecting From The Domain Name Itself To A Page In A Directory?"