比如说我有个index.aspx页面,如果用户没有登录直接查看这个页面,那么我就让他转到登录页面。用户名和密码没有输入,或者错误,都能显示出来。问题是用户登录成功却不能跳到index页面。 那边是通过ashx页面处理传过来success和failed的
。function showLoginResult() {
    var result = xmlHttp.responseText;
    if (result == "succeed") {
        window.history.go(-1);
    } else {
        alert("账号或密码有误");
    }
}

解决方案 »

  1.   

     Javascript 返回上一页 history.go(-1), 返回两个页面: history.go(-2); history.back().也行
      

  2.   

    不知道你返回的result 这个值是不是succeed
    用alert打印出来看看
      

  3.   

     /// <summary>
        /// 防盗链(Filter)
        /// </summary>
        public class MyFilter:ActionFilterAttribute
        {
            public override void OnActionExecuted(ActionExecutedContext filterContext)
            {
                //base.OnActionExecuted(filterContext);
                var user=filterContext.HttpContext.Session["user"];
                if (user == null)
                {
                    filterContext.HttpContext.Response.Write("<script>alert('请登陆...')</script>");
                    //获取刚刚用户浏览的URL(不指定参数值)
                    string url = FormsAuthentication.DefaultUrl;
                    filterContext.HttpContext.Response.Write("<script>window.parent.location.assign('" + url + "')</script>");
                }
            }
        }把这个单独写在一个类里面
    然后在你需要的Action前面这样写
    [类名]
      

  4.   


    浏览器动作history.back()更准确
      

  5.   

    你这种用FORM更爽
    参考
      

  6.   

    window.history.back();  O了
      

  7.   


    =================
    是的,先查看条件是不是满足,另外用,go(-1)这种方式,总归不是太好,不用选用别的跳转方式,比如:window.location.href="index.aspx"
      

  8.   

    window.location.href="index.aspx",用这种方式试了没有呢?