Files
MoonPro.net/MP-TAB/WebUserControls/mod_checkHttps.ascx.cs
T
2018-05-31 14:27:28 +02:00

40 lines
1.1 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)
{
// SOLO SE è abilitato QR reader...
if (memLayer.ML.CRB("EmbedQRead"))
{
// se pagina richiesta in http ma con QR code rimando in https...
bool needHttps = memLayer.ML.CRS("forceSecurePages").IndexOf(titolo) >= 0;
if (needHttps != Request.IsSecureConnection)
{
string newUrl = Request.Url.AbsoluteUri;
// in questo caso scambio http <--> https
if (needHttps)
{
newUrl = newUrl.Replace("http://", "https://");
}
else
{
newUrl = newUrl.Replace("https://", "http://");
}
Response.Redirect(newUrl);
}
}
}
}
}
}