Wednesday, March 21, 2012

Problem loading AJAX in login page

Hi All

My system uses Forms Authentication and in the Login page (first page) I get error in AJAX:

'Sys' is undefined
Sys.Application.initialize();

BUT after I enter, the next page (using AJAX too) opens correct without error AND if I return to login page, works too!
I think that is because after login, the other page create javascript files.. but the code of this pages is the same

So I want to know if this is a permission problem (because forms authentication maybe deny) or I need to do something for Login page create ajax files.

thanks! Oscar.

Could you mind posting your login page code.


LOGIN.aspx.Vb Code:

<formid="form1"runat="server"> <asp:ScriptManagerID="ScriptManager2"runat="server"></asp:ScriptManager> <asp:LabelID="Label1"runat="server"Font-Names="Verdana"Font-Size="Smaller"Style="position: static; top: 0px"Text="Username:"></asp:Label><asp:TextBoxID="txtUsername"runat="server"Style="position: relative;"></asp:TextBox><asp:LabelID="Label2"runat="server"Font-Names="Verdana"Font-Size="Smaller"Style="left: 0px; position: static; top: 0px"Text="Password:"></asp:Label><asp:TextBoxID="txtPassword" runat="server"Style="position: relative;"TextMode="Password"></asp:TextBox> <asp:UpdatePanelID="UpdatePanel1"runat="server"><ContentTemplate><asp:ButtonID="btnSignIn"runat="server"Style="position: static"Text="Sign In"/><asp:PanelID="Panel1"runat="server"Height="50px"Style="position: static"Visible="False"Width="368px"><asp:TextBoxID="txtEmail"runat="server"Style="position: relative"></asp:TextBox> <asp:ButtonID="btnRecover"runat="server"Style="position: relative"Text="Send"/></asp:Panel>

</ContentTemplate> </asp:UpdatePanel></form>

***************************************************************************************

My web.Config:
<?xmlversion="1.0"?><configuration> <appSettings/> <connectionStrings/> <system.web> <compilationdebug="true"> <assemblies> <addassembly="Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> <addassembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/> </assemblies> </compilation> <authenticationmode="Forms"> <formsloginUrl="BackOffice/Login.aspx"defaultUrl="main.aspx"name="Passacaille"timeout="30"path="BackOffice/"/> </authentication> <authorization> <denyusers="?" /> </authorization> <pages> <controls> <addtagPrefix="asp"namespace="Microsoft.Web.UI"assembly="Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> <addtagPrefix="asp"namespace="Microsoft.Web.UI.Controls"assembly="Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> </controls> <tagMapping> <addtagType="System.Web.UI.WebControls.CompareValidator"mappedTagType="Microsoft.Web.UI.Compatibility.CompareValidator, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> <addtagType="System.Web.UI.WebControls.CustomValidator"mappedTagType="Microsoft.Web.UI.Compatibility.CustomValidator, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> <addtagType="System.Web.UI.WebControls.RangeValidator"mappedTagType="Microsoft.Web.UI.Compatibility.RangeValidator, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> <addtagType="System.Web.UI.WebControls.RegularExpressionValidator"mappedTagType="Microsoft.Web.UI.Compatibility.RegularExpressionValidator, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> <addtagType="System.Web.UI.WebControls.RequiredFieldValidator"mappedTagType="Microsoft.Web.UI.Compatibility.RequiredFieldValidator, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> <addtagType="System.Web.UI.WebControls.ValidationSummary"mappedTagType="Microsoft.Web.UI.Compatibility.ValidationSummary, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> </tagMapping> </pages> <httpHandlers> <removeverb="*"path="*.asmx"/> <addverb="*"path="*.asmx"validate="false"type="Microsoft.Web.Script.Services.ScriptHandlerFactory, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> <addverb="GET"path="ScriptResource.axd"type="Microsoft.Web.Handlers.ScriptResourceHandler"validate="false"/> </httpHandlers> <httpModules> <addname="WebResourceCompression"type="Microsoft.Web.Handlers.WebResourceCompressionModule, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> <addname="ScriptModule"type="Microsoft.Web.UI.ScriptModule, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> </httpModules> </system.web> <locationpath="BackOffice/Login.aspx"> <system.web> <authorization> <allowusers="?" /> </authorization> </system.web> </location> </configuration>


I believe that the problem still in web.config


The Problem is in your Login.aspx page, You forgot to put a ScriptManager.


There's a ScriptManager there.

My guess is that the deny authorization means the scripts (WebResource.axd, ScriptResource.axd) aren't being loaded. Try allowing those resources to get through?

You can easily tell if that's the problem by using Fiddler or Nikhil's Web Development Helper to monitor the HTTP traffic to see which request is failing.


Steve,
You're right, when I allow resources page works

This is the code that I added and now always generate javascript for asp.net

<locationpath="ScriptResource.axd">
<system.web>
<authorization>
<allowusers="?" />
</authorization>
</system.web>
</location>

thank you all

No comments:

Post a Comment