prama
prama

Reputation: 61

ASP.NET Forms Authentication with Android Browser

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();
}

Upvotes: 3

Views: 1314

Answers (2)

Darren
Darren

Reputation: 2034

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.

Upvotes: 0

Matt Hudson
Matt Hudson

Reputation: 7348

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.

Upvotes: 1

Related Questions