ASP.NET Forms Authentication with Android Browser

孤街醉人 提交于 2019-12-23 18:06:48

问题


I'm using ASP.NET Forms Authentication with a simple way. The authentication use a cookie for store the credentials.

Works perfectly in browsers like: Desktop: Chrome, Safari, IE, ... Mobile: iPhone Browser, Opera Mobile ...

I press the button form's authentication and i redirect to the app page.

BUT, in Android browser i press the button and nothing.

The configuration of ASP.NET Forms Authentication is simple:

<authentication mode="Forms">
 <forms loginUrl="MLogin.aspx"
     timeout="30"
     name=".MOBAUTH"
     path="/"
     defaultUrl="Main.aspx"
     cookieless="AutoDetect">
  <credentials passwordFormat="Clear">
   <user name="dev" password="123456"/>
  </credentials>
 </forms>
</authentication>
<authorization>
 <deny users="?" />
</authorization>

Does anyone have any idea what might be happening?

Complementing...

MLogin.aspx use a simple method for authenticate the user:

private void authenticate()
{
    if (FormsAuthentication.Authenticate("dev", this.txtPass.Text.Trim()))
        FormsAuthentication.RedirectFromLoginPage("dev", true);

    Response.End();
}

回答1:


The reason is the Response.End(). That function prematurely kills your stream of data. There is no need for it at all.

Different browsers handle the Response.End() in different ways. Some will render the page even though you ended the stream, and some will not render it.




回答2:


Check the "expires" parameter in the response's Set-Cookie header field, and make sure your phone is set to the correct time & date. If the browser thinks the cookie is already past its expiry date, it won't store it.



来源:https://stackoverflow.com/questions/4134546/asp-net-forms-authentication-with-android-browser

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!