问题描述:
我登陆进系统主页,然后再打开一个新页面,把系统地址再复制进去(效果:判断cookie直接进去主页)
这时我随便把一个页面注销(清除cookies)并且跳到登录页,然后切换到没点注销的那个页,里面权限操作都可以点,这时错误一大堆了,然后我想要的是里面任何请求,都要进行判断,然后我就用了IHttpModule 截取是截取到了,但是我把地址重定向,变成我请求的地址(比如后台的Index/xml_doc 的方法),变成请求context.Response.Redirect("/");//这个代表跳到登录页
我页面上有个 弹出曾 单击弹出div 里面是iframe ,然后弹出的iframe的地址变成 主页的地址,- -!,我要的是整个页面重定向到 登录页啊。而不是请求页改为登录页。
private void Application_BeginRequest(Object source,
EventArgs e)
{
// Create HttpApplication and HttpContext objects to access
// request and response properties.
HttpApplication application = (HttpApplication)source;
HttpContext context = application.Context; // string s = context.Request.Url.ToString();
string filePath = context.Request.FilePath;
string fileExtension =
VirtualPathUtility.GetExtension(filePath); string path = Regex.Match(filePath, @"[Index]+").ToString(); if (path == "Index")
{ if (Common.IsLogin() == false) //判断用户是否登陆 ///大侠们看这边!!!!!
{
context.Response.End();
context.Response.Redirect("/");
}
}
//if (fileExtension.Equals("/Index/Index"))
//{
// // string s = context.Request.Url.AbsolutePath.ToString();
// context.Response.Write("<h1><font color=red>" +
// "VerificationModule: Beginning of Request" +
// "</font></h1><hr>");
//}
}
我登陆进系统主页,然后再打开一个新页面,把系统地址再复制进去(效果:判断cookie直接进去主页)
这时我随便把一个页面注销(清除cookies)并且跳到登录页,然后切换到没点注销的那个页,里面权限操作都可以点,这时错误一大堆了,然后我想要的是里面任何请求,都要进行判断,然后我就用了IHttpModule 截取是截取到了,但是我把地址重定向,变成我请求的地址(比如后台的Index/xml_doc 的方法),变成请求context.Response.Redirect("/");//这个代表跳到登录页
我页面上有个 弹出曾 单击弹出div 里面是iframe ,然后弹出的iframe的地址变成 主页的地址,- -!,我要的是整个页面重定向到 登录页啊。而不是请求页改为登录页。
private void Application_BeginRequest(Object source,
EventArgs e)
{
// Create HttpApplication and HttpContext objects to access
// request and response properties.
HttpApplication application = (HttpApplication)source;
HttpContext context = application.Context; // string s = context.Request.Url.ToString();
string filePath = context.Request.FilePath;
string fileExtension =
VirtualPathUtility.GetExtension(filePath); string path = Regex.Match(filePath, @"[Index]+").ToString(); if (path == "Index")
{ if (Common.IsLogin() == false) //判断用户是否登陆 ///大侠们看这边!!!!!
{
context.Response.End();
context.Response.Redirect("/");
}
}
//if (fileExtension.Equals("/Index/Index"))
//{
// // string s = context.Request.Url.AbsolutePath.ToString();
// context.Response.Write("<h1><font color=red>" +
// "VerificationModule: Beginning of Request" +
// "</font></h1><hr>");
//}
}
解决方案 »
- .NET怎么把decimal转换成百分比?
- Gridview里的dropdownList
- winForm中如何实现日历备忘功能
- 有关下拉树菜单JS样式
- AJAX 关于respoint.write();
- 求源码:不同的角色中有不同的用户,不同的用户看到不同的菜单,就是一个权限控制的源码!
- |zyciis| 乘慕白兄在. 我前两天发了一个网页生成JPG的WinForm程序到您的邮箱. 不知这个WinForm程序能不能改在WebForm中用呢
- Vs2005的安装环境
- 不能加载类型global.asaz
- 这个问有没有人能够解决啊,在CSDN上面问了N遍了,但是还是没有人回答。
- 有没有替代“IETester”的工具,“IETester”它打开网页就死掉了
- 关于腾讯微博调用的问题
if (Common.IsLogin() == false) //判断用户是否登陆 ///大侠们看这边!!!!!
{
//context.Response.End(); //这句忽略
context.Response.Redirect("/");
}
<forms loginUrl="~/Account/LogOn" timeout="2880"/>
</authentication>指向你的登录页
这个是一旦访问这个 加特性的Controller 会跳转到 登录页,“此网页包含重定向循环”
就要这效果而已,刚刚看了很多filter 。好难理解呀~例子也下了个,看不大懂,正在费解
学习了一早上的Filter,结果还是一样啊,没cookies的时候我要整个页面跳转到登陆页,然后这个效果跟刚刚一样,直接把请求的地址替换成登录页- -,这个明显不行啊。filterContext.RequestContext.HttpContext.Response.Redirect("~/Login/LoginPage");
protected override bool AuthorizeCore(HttpContextBase httpContext)
{
string url = httpContext.Request.RawUrl;
if (url.Equals("/") || url.Contains("/Home/LoginOn/") || url.Contains("/Home/CheckCode"))
{
return true;
}
if (CC6UU_Admin.Commom.AdminInfo.Session == null)
{
httpContext.Response.StatusCode = 404;
return false;
}
else
{
return true;
}
} public override void OnAuthorization(AuthorizationContext filterContext)
{
base.OnAuthorization(filterContext);
if (filterContext.HttpContext.Response.StatusCode == 404)
{
filterContext.Result = new RedirectResult("/");
}
}
..一样哒。反正我就是在请求方法前 截取请求,然后这时不管怎么定向,效果等于把请求的地址换成登陆也地址。。谢谢各位了,结贴了
我的解决办法是 ,直接先 clear 然后 end 直接不让用户看就是