Решение:

В MasterPage

protected override void OnPreRender(EventArgs e)
{
if (EnforceSSL)
{
if (!Request.IsSecureConnection)
{
Response.Redirect(
Request.Url.AbsoluteUri.ToLower().Replace(
"http://", "https://"), true);
}
}
else if (Request.IsSecureConnection)
{
Response.Redirect(Request.Url.AbsoluteUri.ToLower().Replace(
"https://", "http://"), true);
}
}


public bool EnforceSSL
{
get
{
if (ViewState["enforceSSL"] != null)
{
return (bool)ViewState["enforceSSL"];
}
else
{
return false;
}
}
set
{
ViewState["enforceSSL"] = value;
}
}

На странице

protected override void OnInit(EventArgs e)
{
(Master as BalloonShop).EnforceSSL = true;
base.OnInit(e);
}

 

Опубликовано в ASP.NET