More control on ASP.Net MVC's Authorize; to keep AJAX requests AJAXy
I have some action methods behind an Authorize like: [AcceptVerbs(HttpVerbs.Post), Authorize] public ActionResult Create(int siteId, Comment comment) { The problem I have is that I'm sending a request through AJAX to Comment/Create with X-Requested-With=XMLHttpRequest which helps identify the request as AJAX. When the user is not logged in and hits the Authorize wall it gets redirected to /Account/LogOn?ReturnUrl=Comment%2fCreate which breaks the AJAX workflow. I need to be redirected to /Account/LogOn?X-Requested-With=XMLHttpRequest Any ideas how that can be achieved? Any ways to gain more