bahman7210
دوشنبه 07 آذر 1390, 20:31 عصر
چه جوری میشه به session دسترسی پیدا کرده در کلاسهایی که Ui نیستند؟؟؟؟
public
class SecurityHttpModule : System.Web.UI.Page , IHttpModule
{
public SecurityHttpModule() { }
public void Init(HttpApplication context)
{
context.BeginRequest +=
new EventHandler(Application_BeginRequest);
}
private void Application_BeginRequest(object source, EventArgs e)
{
HttpContext context = ((HttpApplication)source).Context;
string ipAddress = context.Request.UserHostAddress;
if (IsValidIpAddress(ipAddress))
{
if (Cache["Groups"] != null)
//context.Response.StatusCode = 403; // (Forbidden)
context.Response.Redirect(
"http://yahoo.com",false);
}
}
private bool IsValidIpAddress(string ipAddress)
{
return true;
return (ipAddress == "127.0.0.1");
}
public void Dispose() { /* clean up */ }
}
public
class SecurityHttpModule : System.Web.UI.Page , IHttpModule
{
public SecurityHttpModule() { }
public void Init(HttpApplication context)
{
context.BeginRequest +=
new EventHandler(Application_BeginRequest);
}
private void Application_BeginRequest(object source, EventArgs e)
{
HttpContext context = ((HttpApplication)source).Context;
string ipAddress = context.Request.UserHostAddress;
if (IsValidIpAddress(ipAddress))
{
if (Cache["Groups"] != null)
//context.Response.StatusCode = 403; // (Forbidden)
context.Response.Redirect(
"http://yahoo.com",false);
}
}
private bool IsValidIpAddress(string ipAddress)
{
return true;
return (ipAddress == "127.0.0.1");
}
public void Dispose() { /* clean up */ }
}