Click here to Skip to main content
15,936,014 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi All

suppose i have two sites are and

Earlier, my files were on (non-secure) now i have migrated them on (secure). So now there are no files on (non-secure).

now i want to set a page(say default.aspx) on (non-secure) that redirect me to (secure site)?

how can i do this?


What I have tried:

Updated 29-Jan-23 4:41am


You can even redirect your site using DNS entry from your server. That way you do not have to keep default page on your old site. just made one entry to redirect page on the new https location.

If you want to redirect using your default page then you can use Response.Redirect to change page to https.

Hope it works for you,
Share this answer
kk2014 12-Oct-12 4:47am    
hi amit,
thanks for the quick reply. let i know you update...
AmitGajjar 12-Oct-12 4:49am    
Your welcome.
kk2014 12-Oct-12 5:51am    
hi amit,

is it possible that without i hardcode in my application, if i write or in adress bar, then it directly redirect to
i don't want to write code in
which setting i do in redirect me to https://?
AmitGajjar 12-Oct-12 5:55am    
You can get the domain name in the page and then build the URL by appending https in URL and redirect on that location.
kk2014 12-Oct-12 7:29am    
hi amit,

i have putted physical page and redirecting to https://.
it works for me.

There are several methods to do this. Check this link:[^]

I think that the simplest one is setting up a custom error page. Try and let us know!

Share this answer
Try following code in global.asax

//This code work only on server
void Application_BeginRequest(object sender, EventArgs e) 
        if (HttpContext.Current.Request.Url.ToString().ToLower().Contains("http:"))
            Response.Redirect(HttpContext.Current.Request.Url.ToString().ToLower().Replace("http:", "https:"));

Share this answer
[no name] 12-Oct-12 5:06am    
my 5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900