303重定向仅适用于Chrome?

时间:2015-06-15 17:49:09

标签: php forms redirect post get

这是我在过去几天一直在处理的一个问题,但我不能为我的生活找出为什么303重定向仅适用于Chrome。我创建了一个post,redirect,get函数来处理表单数据,以避免在刷新页面时重复提交。

  //************ Try Block ************************************//
sqlStr = "select LoginId from users where LoginID like '" + sUserName.Trim() + "' and CurrentPassword like '" + objFun.EncryptData(sPassword.Trim()) + "'";
                    string sDbUserName = objFun.RunSelectQueryAndReturnString(sqlStr);
                    if (sUserName.ToUpper().Trim() == sDbUserName.ToUpper().Trim())
                    {
                        sqlStr = "select CurrentStatus from users where LoginID like '" + sUserName.Trim() + "' and CurrentPassword like '" + objFun.EncryptData(sPassword.Trim()) + "'";
                        int iStatus = Convert.ToInt32(objFun.RunSelectQueryReturnFirstFieldOfFirstRecord(sqlStr));
                        if (iStatus != 1)
                        {
                            Response.Cookies.Add(new HttpCookie("UserName", sUserName));


                            Session["LoginID"] = sUserName;    // From this line my Code goes to Catch  Block

                        Session["LoginTime"] = DateTime.Now;
                        sqlStr = "";
                        sqlStr = "Update Users set CurrentStatus=1 where LoginID like '" + sUserName + "'";
                        objFun.RunSelectQuery(sqlStr);
                        if (Login1.RememberMeSet == true)
                        {
                            Response.Cookies.Add(new HttpCookie("UserNameHistory", Login1.UserName));
                        }
                        sqlStr = "";
                        objFun.GenerateLog("USERLOGIN", "Logged in into Website", sUserName, 2, 0);
                        Response.Redirect("Home.aspx");// ,true  );

                        //throw new Exception("Unable to redirect");
                    }
                    else
                    {
                        throw new Exception("User is already logged in");
                    }

///****************************Catch Block********************************/

       catch (Exception ex)
        {
            Login1.FailureText = ex.Message;              
        }

Exception I got at RUNTIME:
 {System.Web.HttpException: Session state can only be used when enableSessionState is set to true, either in a configuration file or in the Page directive. Please also make sure that System.Web.SessionStateModule or a custom session state module is included in the <configuration>\<system.web>\<httpModules> section in the application configuration.
   at System.Web.UI.Page.get_Session()
   at Login.Login1_Authenticate(Object sender, AuthenticateEventArgs e) 

我只是不明白为什么这在Chrome浏览器之外无效。它在firefox和safari中生成的最终结果是一个空表单,就好像你是第一次查看页面一样。在firefox和safari中遇到此块后,会话和后置数组似乎为空。

1 个答案:

答案 0 :(得分:1)

You need to pass the additional parameters to the header call. From the user comments on the manual page时突出显示div:

// 303 See Other
header("Location: /foo.php",TRUE,303);