by Jim
Sep 14, 2007 5:34 PM
We have a site that uses forms authentication, with the exception of a few pages. In one of these pages, we were getting a bunch of syntax errors and weird behavior, but only when the page was accessed anonymously.
Firebug was showing syntax errors in the ScriptResourse.axd file. This is supposed to programmatically render script for the UpdatePanels and such, but was rendering the login.aspx page instead; authentication had failed for the anonymous user, and the request was redirected to the login page. Of course, this is html and not valid javascript, thus the syntax error.
Because the script includes didn't render, and didn't define the classes needed for the UpdatePanels, the page also had errors on the following lines:
Sys.Application.initialize();
Sys.WebForms.PageRequestManager._initialize('ScriptManager',
document.getElementById('MasterPageForm'));
var mngr = Sys.WebForms.PageRequestManager.getInstance();
This solution to this issue is to allow anonymous access to the ScriptResource.axd "file" in web.config, like so:
<location path="ScriptResource.axd">
<system.web>
<authorization>
<allow users="?"/>
</authorization>
</system.web>
</location>
And while you're at it there's a WebResource.axd as well:
<location path="WebResource.axd">
<system.web>
<authorization>
<allow users="?"/>
</authorization>
</system.web>
</location>