52 lines
1.8 KiB
C#
52 lines
1.8 KiB
C#
using SteamWare;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
|
|
namespace MoonProTablet.WebUserControls
|
|
{
|
|
public partial class mod_checkHttps : SteamWare.UserControl
|
|
{
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!Page.IsPostBack)
|
|
{
|
|
bool forceHttps = memLayer.ML.CRB("forceHttps");
|
|
if (memLayer.ML.CRB("EmbedQRead") || forceHttps)
|
|
{
|
|
#if DEBUG
|
|
// in debug NON gestisco cambio http/https...
|
|
bool needHttps = true;
|
|
|
|
|
|
#else
|
|
// se è FORZATO da web.config
|
|
// se è FQND: iis01.egalware.com lo è, iis01 NO...
|
|
bool isFQDN = Request.Url.Host.IndexOf(".") > 0;
|
|
// se pagina richiesta in http ma con QR code rimando in https...
|
|
bool isSecuredPage = memLayer.ML.CRS("forceSecurePages").IndexOf(titolo) >= 0;
|
|
|
|
bool needHttps = forceHttps || isFQDN || isSecuredPage;
|
|
#endif
|
|
if (needHttps != Request.IsSecureConnection)
|
|
{
|
|
string newUrl = Request.Url.AbsoluteUri;
|
|
// in questo caso scambio http <--> https
|
|
if (needHttps || forceHttps)
|
|
{
|
|
newUrl = newUrl.Replace("http://", "https://");
|
|
}
|
|
else
|
|
{
|
|
newUrl = newUrl.Replace("https://", "http://");
|
|
}
|
|
Response.Redirect(newUrl);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |