We have a simple requirement to use https for certain specific pages in a asp.net 4.0 web application. For checking our implementation, we deployed a simple asp.net 4.0 app to IIS 7. The app has been coded to redirect the default.aspx page to securepage.aspx over https based on a web.config flag.
protected void Page_Load(object sender, EventArgs e)
{
Uri requestUri = Page.Request.Url;
UriBuilder builder = new UriBuilder("https", requestUri.Host, requestUri.Port, "SecurePage.aspx");
string secureUrl = builder.Uri.ToString();
if (bool.Parse(ConfigurationManager.AppSettings["UseSecure"]))
{
Response.Redirect(secureUrl, true);
}
else
{
Response.Write(secureUrl);
}
}
But after we deploy this app on IIS 7 and load the default.aspx page, it shows “Internet Explorer cannot display the webpage”. But if we turn the config flag off, it displays the page properly. The app has http binding on port 82 and https on port 444.
Can anybody point me in where we are going wrong.
When you type in front
httpsthen the browser is go on port443and not on 444, so to movit on your custom port you need to type it as.