return (int)System.Web.HttpContext.Current.Session["AdminID"];
return (int)System.Web.HttpContext.Current.Session["UserType"];
return (int)System.Web.HttpContext.Current.Session["CompanyID"];
set { System.Web.HttpContext.Current.Session["CompanyID"] = value; }
return (string)System.Web.HttpContext.Current.Session["UserTheme"];
set { System.Web.HttpContext.Current.Session["UserTheme"] = value; }
return (int)System.Web.HttpContext.Current.Session["BranchID"];
using System;
using System.Web;
using System.Web.UI;
using System.Web.Configuration;
using System.Text;
using System.Security.Cryptography;
using System.IO;
/// <summary>
/// Ashish Srivastava
/// 21 Sep 2017
///
/// </summary>
public class PreInitModule : IHttpModule
{
#region IHttpModule Members
public void Dispose()
{
//throw new NotImplementedException();
}
public void Init(HttpApplication context)
{
context.PreRequestHandlerExecute += HandlePreRequest;
}
void HandlePreRequest(object sender, EventArgs e)
{
var page = HttpContext.Current.CurrentHandler as System.Web.Mvc.MvcHandler;
if (page != null)
{
//page.PreInit += delegate
//{
if (HttpContext.Current.Request.Path.ToLower().Contains("/admin/"))
{
if (HttpContext.Current.Session["AdminID"] != null)
{
if (HttpContext.Current.Session["CompanyID"] != null)
{
if (HttpContext.Current.Session["BranchID"] != null) return;
var loginPageBranch = WebConfigurationManager.AppSettings["LoginPagePath"] ?? "~/Admin/Branch";
if (HttpContext.Current.Request.Path.Contains(loginPageBranch.Substring(loginPageBranch.LastIndexOf("/") + 1)) == false
&& HttpContext.Current.Request.Path.Contains("Branch") == false
&& HttpContext.Current.Request.Path.Contains("BillingCompanyReport.aspx") == false
&& HttpContext.Current.Request.Path.Contains("UserCompanyMapping.aspx") == false
&& HttpContext.Current.Request.Path.Contains("AddCompany.aspx") == false
&& HttpContext.Current.Request.Path.Contains("AddBranch.aspx") == false
&& HttpContext.Current.Request.Path.Contains("InvoceHeadSettings.aspx") == false
//&& HttpContext.Current.Request.Path.Contains("ForgetPassword.aspx") == false
)
{
HttpContext.Current.Response.Redirect(loginPageBranch, true);
}
else
{
return;
}
}
var loginPageCompany = WebConfigurationManager.AppSettings["LoginPagePath"] ?? "~/Admin/Company";
if (HttpContext.Current.Request.Path.Contains(loginPageCompany.Substring(loginPageCompany.LastIndexOf("/") + 1)) == false
&& HttpContext.Current.Request.Path.Contains("Company") == false
&& HttpContext.Current.Request.Path.Contains("AddCompany.aspx") == false
&& HttpContext.Current.Request.Path.Contains("BillingCompanyReport.aspx") == false
&& HttpContext.Current.Request.Path.Contains("UserCompanyMapping.aspx") == false
&& HttpContext.Current.Request.Path.Contains("AddCompany.aspx") == false
&& HttpContext.Current.Request.Path.Contains("AddBranch.aspx") == false
&& HttpContext.Current.Request.Path.Contains("InvoceHeadSettings.aspx") == false
)
{
HttpContext.Current.Response.Redirect(loginPageCompany, true);
}
else
{
return;
}
}
var loginPage = WebConfigurationManager.AppSettings["LoginPagePath"] ?? "~/Login?Session=Expire";
if (HttpContext.Current.Request.Path.Contains(loginPage.Substring(loginPage.LastIndexOf("/") + 1)) == false)
{
HttpContext.Current.Response.Redirect(loginPage, true);
}
else
{
}
}
}
}
#endregion
}