当前位置:编程学习 > C#/ASP.NET >>

.net mvc3验证Session过期页面跳转问题

本人接触MVC3.0不久,做了一点小练习,现在遇到一些小问题。
这个是我写的BaseController方法
public class BaseController : Controller 
    {
        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            //验证当前请求的Session有没有过期
            if (Web.Comm.Comm.CheckSessionTimeOut())
            {
                filterContext.Result = new ViewResult();
                Response.Clear();
                Response.StatusCode = 500;
                Response.Redirect("~/Login/PageError");
            }
            else 
            {
                base.OnActionExecuting(filterContext);
            }
        }
    }
这个是Web.Comm.Comm中写的验证session是否过期的方法
public static bool CheckSessionTimeOut()
        {
            if (HttpContext.Current.Session["Account"] != null)
            {
                return false;
            }
            else
            {
                return true;
            }
        }
这个是我写的测试Controller
public class DemoController:BaseController
{
  public ActionResult Index()
 { 
   //todo something
 }

  [httppost]
  public void Submit()
 {
  //todo something
 }
}
现在遇到的问题是当session过期的时候,Index方法调用OnActionExecuting方法的时候会正确跳转到PageError页面,但是在执行Submit方法的时候跳转就出错,不知道如何解决,请大虾们帮帮忙: --------------------编程问答-------------------- 顶一下,各位大神帮帮忙~
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,