I have a .aspx
with a static method decorated with the [WebMethod] attribute and a ScriptManager on the page, so that the WebMethod can be called with PageMethods.MethodName()
. Forms authentication is enabled.
This works well in all scenarios except where the WebMethod is invoked on an expired session. When that happens, the service returns HTTP 401 and a username/password dialog pops up! I would much rather the user be redirected, as they are with any other request (including asynchronous postbacks). Is there a way to trap that specific condition, or to configure the application to do the right thing when presented with this case?
edited to correct actual HTTP status code - it's an HTTP 401, not a 403