I have an asp.net 4.0 application that contains a web service that is used to render some data through ajax. I have the service attached to my scriptmanager through a script reference. My site is protected by forms authentication.
<ajaxtoolkit:toolkitscriptmanager id="ScriptManager1" runat="server" enableviewstate="false"
asyncpostbacktimeout="3600" scriptmode="Auto" enablepagemethods="true" CombineScripts="true" EnableCdn="true" >
<Services>
<asp:ServiceReference Path="~/WebServices/PortalWebService.asmx" />
</Services>
</ajaxtoolkit:toolkitscriptmanager>
When i try and call the webservice method using javascript and my auth ticket is still valid everything is hunky dory and i get my response back perfectly fine. But if my auth ticket is expired when the javascript call is made then the server pops up a window asking for me to authenticate.
The server is responding with a 401 request for basic authentication! Which when you enter valid information does absolutely nothing but pop up the window again.
I've attached an on error handler to my service method call and it is fired after the user has been prompted for a window that doesn't work. How do i fix this? It needs to either report the error to the onerror handler or redirect the user (which is not likely to happen).
Fixed it by disabling basic and digest authentication in IIS (Forms authentication was already enabled). Once i did this, it used forms authentication with the correct behavior.