jquery asmx and web.config
Please help! We use jquery to call a remote asmx in .net.
we only want logged-in users to hit this service. we put it under a protected location (web.config), it works fine but when the session expires we get the login html page back. I've read som开发者_如何学Goe other articles from people with the same problem.
my question is, if we moved the asmx out to an unprotected folder and added the following condition if (User.Identity.IsAuthenticated) to catch if the user is not logged-in would that be the same?
I hope I explained my question properly.
Thanks
You can move the web service (.asmx) to an unprotected folder or add explicit access to the service in your web.config
(within <configuration>
section)
<location path="[filename].asmx">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>
Then, as you had already thought, do a check in the webservice to verify authentication and have your response indicate to the page a need to re-login.
精彩评论