1.
response.redirect(Request.ApplicationPath + "/Homepage.aspx");
2.
if(Request.ServerVariables["HTTPS"].ToLower() == "off")
{
strBaseURL = "http://";
}
else
{
strBaseURL = "https://";
}
strBaseURL = strBaseURL + Request.ServerVariables["SERVER_NAME"] + ":";
strBaseURL = strBaseURL + Request.ServerVariables["SERVER_PORT"];
strBaseURL = strBaseURL + Request.ServerVariables["URL"];
3.
1.) You could add a few lines of code
your Global.asax file for the
Application_BeginRequest event handler. This handler would simply check the
current page request, via Request.Path.EndsWith("/PageName.aspx"), for
either of the two pages you need
page requested needs
if the request was already made via HTTPS. If not, redirect
Request.Path.Replace("http://", "https://"). If the requested page is not
one of those two pages yet Request.IsSecureConnection returns True, then
redirect
connection.
2.) Another alternative is
each project, or for the entire server via machine.config, that reads a
custom configuration section from your web.config file for the pages and
directories that need
should be ignored (i.e. requests that should remain in the protocal they
were requested). This class would read those pages into a searchable
collection and test for a match with the current requested page from the
BeginRequest event once again. A decision
4.
Switching Between HTTP and HTTPS Automatically: Version 2
http://www.codeproject.com/Articles/7206/Switching-Between-HTTP-and-HTTPS-Automatically-Ver5.
if (!Request.IsLocal && !Request.IsSecureConnection)
{
string redirectUrl = Request.ApplicationPath + "/test.html?amount=" + amount;
//redirectUrl = Request.Url.ToString().Replace("http:", "https:");
redirectUrl = redirectUrl.ToString().Replace("http:", "https:");
Response.Redirect(redirectUrl);
}
6.
Global.asax
void Application_BeginRequest(object sender, EventArgs e)
{
int i = Request.Path.IndexOf("securepage.html");
//Request.Path="/index.aspx"
if (i != -1) //is securepage.html,
{
if (!Request.IsSecureConnection) //Request.IsSecureConnection=false request is http
{
string path = string.Format("https{0}", Request.Url.AbsoluteUri.Substring(4));
//Request.Url.AbsoluteUri="http://localhost:1234/securepage.html"
//path="https://localhost:1234/securepage.html"
Response.Redirect(path);
}
}
else//any other page{}
}
7.
void Application_BeginRequest(object sender, EventArgs e)
{
if (Request.Path.EndsWith("/index.aspx"))
{
if (!Request.IsSecureConnection)// http
{
string securePath=Request.Url.AbsoluteUri.ToString().Replace("http://", "https://");
//securePath=https://
Response.Redirect(securePath);
}
}
else
{
}
}
8.
if (!Request.IsLocal && !Request.IsSecureConnection)
{
string s1 = Request.ApplicationPath + "index.asxp";
// Request.ApplicationPath=”/”;
// s1= “/index.aspx”
string s2 = Request.Url.ToString().Replace("http:", "https:");
// Request.Url=http://localhost:1234/index.aspx
// s2= https://localhost:1234/index.aspx
Response.Redirect(s1);
}
9.
string strBaseURL = "";
if (Request.ServerVariables["HTTPS"].ToLower() == "off")
{
strBaseURL = "http://";
}
else
{
strBaseURL = "https://";
}
strBaseURL = strBaseURL + Request.ServerVariables["SERVER_NAME"] + ":";
//https://localhost:
strBaseURL = strBaseURL + Request.ServerVariables["SERVER_PORT"];
//https://localhost:1234
strBaseURL = strBaseURL + Request.ServerVariables["URL"];
//https://localhost:1234/test.aspx
strBaseURL = strBaseURL.Replace("LoadGLVisa.aspx", "index.aspx");
//https://localhost:1234/index.aspx
Response.Redirect(strBaseURL);
No comments:
Post a Comment