Short version: What's the best way to stay on the same page to run a second AJAX call after an AJAX ASP.NET Membership Authentication response is received?
Long version: Imagine a web-based Paint program built in ASP.NET MVC. The user paints a picture, during which time the user's session has timed out. The user hits "save" and is prompted with an AJAX dialog, "Your session has timed out. Please enter your credentials below." (See jQuery Forms Authentication with ASP.NET MVC for how to do AJAX authentication.) After entering valid credentials, the user is re-authenticated.
Typically, at this point, users are redirected to returnUrl
, as is evident by MVC's default login method signature:
public ActionResult LogOn(LogOnModel model, string returnUrl)
However, in this case, I would like to stay on the same page and instead make an AJAX call to my handler, SaveArt()
, which will write the user's work to the database. I could hijack returnUrl
to have it contain the name of the subsequent Javascript function I'd like to call, but the only way I can think to execute it from the client is with the dreaded eval
, which does not at all seem secure. Is there another way to fully AJAXify this process? What are the dangers of using eval
here, to run a function whose name is returned by the server?