我用下面的代码登录到我的asp.net网站。 与框架4它在网络凉亭成功运行,但在Safari浏览器(iPhone,iPad的)没有工作,只有当我点击登录按钮,他刷新页面,无法登陆。
Session["AdminID"] = DT.Rows[0]["Id"].ToString();
Response.Cookies.Add(new HttpCookie("SuperAccountId", DT.Rows[0]["Id"].ToString()));
Response.Cookies["SuperAccountId"].Expires = System.DateTime.Now.AddDays(1);
Response.Cookies.Add(new HttpCookie("SuperAccountName", DT.Rows[0]["Username"].ToString()));
Response.Cookies["SuperAccountName"].Expires = System.DateTime.Now.AddDays(1);
FormsAuthentication.SetAuthCookie(Session["AdminID"].ToString(), true);
FormsAuthentication.RedirectFromLoginPage("admin", true);
//create a cookie
HttpCookie myCookie = new HttpCookie("FirstLoginCookies");
//Add key-values in the cookie
myCookie.Values.Add("first", "1");
//set cookie expiry date-time. Made it to last for next 12 hours.
myCookie.Expires = DateTime.Now.AddHours(12);
//Most important, write the cookie to client.
Response.Cookies.Add(myCookie);
if (Request.QueryString["ReturnUrl"] != null)
{
string redirectURL = Request.QueryString["ReturnUrl"].ToString();
Response.Redirect("~" + redirectURL);
}
else
{
Response.Redirect("~/admin");
}