I have some authorization action methods like:
[AcceptVerbs(HttpVerbs.Post), Authorize]
public ActionResult Create(int siteId, Comment comment) {
The problem is that I am sending a request via AJAX for comments / creation using
X-Requested-With=XMLHttpRequest
which helps to identify the request as AJAX. When the user does not log in and hit the authorization wall, he is redirected to
/Account/LogOn?ReturnUrl=Comment%2fCreate
which breaks the AJAX workflow. I need to redirect to
/Account/LogOn?X-Requested-With=XMLHttpRequest
Any ideas how this can be achieved? Any ways to get more control over what happens when I request authorization?
source
share