Asp.Net Forms Authentication when using iPhone UIWebView Asp.Net Forms Authentication when using iPhone UIWebView asp.net asp.net

Asp.Net Forms Authentication when using iPhone UIWebView


I had exactly the same problem, but with another device (NokiaN8), and also traced the problem back to the User-Agent.

IIS uses regular expressions to match against the User-Agent string. The root of the problem was that it didn't have any matching regular expressions for the specific device, and ended up in one of the lowest levels of match, where the Default properties were used.The default properties said that the browser didn't support cookies.

Solution:

  1. Add a folder in your web project named App_Browsers (right-click the project, choose: Add > Add ASP.NET Folder > App_Browsers).
  2. Add a file in that folder (right-click, choose: Add > New Item). The file can have any name, but must have the .browser ending.
  3. Add a good matching expression and the correct capabilities (or add changes to the Default).

Two examples:

<browsers>  <browser id="NokiaN8" parentID="Mozilla">    <identification>      <userAgent match="NokiaN8" />    </identification>    <capabilities>      <capability name="browser" value="NokiaN8" />      <capability name="cookies" value="true" />     </capabilities>   </browser> </browsers>

Or change the default:

<browsers>  <browser refID="Default">     <capabilities>       <capability name="cookies" value="true" />     </capabilities>  </browser></browsers>

More info: Browser Definition File Schema


The solution we found was to create a file (generic.browser) and include this xml to tell the web server that "Mozilla" and the Default browser settings should all support cookies.

<browser refID="Mozilla" >    <capabilities>        <capability name="cookies"  value="true" />    </capabilities></browser>


This is fixed in ASP.NET 4.5 and all browsers are assumed to support cookies, so the extra .browser file won't be needed.