Steps to convert your http page to https: - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Steps to convert your http page to https:

Use the following code in your index or home page of application.

string strURL = Request.Url.ToString();
Array arrURL = strURL.Split('/');
string strHttpPath;
string strHttpsPath;
Array arrHttpPath;
strHttpPath = "http://" + arrURL.GetValue(2).ToString() + Request.ApplicationPath;
strHttpsPath = "https://" + arrURL.GetValue(2).ToString() + Request.ApplicationPath;
arrHttpPath = strHttpPath.ToCharArray();
if (arrHttpPath.GetValue(strHttpPath.Length - 1).ToString() == "/")
{
strHttpPath = strHttpPath.Substring(0, strHttpPath.Length - 1);
strHttpsPath = strHttpsPath.Substring(0, strHttpsPath.Length - 1);
}
//Session["HttpPath"] = strHttpPath; //When http path is required uncomment it and use this session value while redirecting it to other page.
Session["HttpsPath"] = strHttpsPath;

Now use Response.Redirect method in following way.

Code

Response.Redirect(Session["HttpsPath"].ToString() + "/Contents/ThankYou.aspx");

Note: My Thankyou page is located inside Contents folder.

Incase of using javascript to redirect the page, follow the below code

location.href = '<%=Session["HttpsPath"].ToString()%>' + "/Contents/ ThankYou.aspx ";


------------------------------------

[link=http://www.clickssl.com]http:www.clickssl.com[/link]

Sign In or Register to comment.