In an ASP.NET MVC3 application
I have a base controller where I override some functions.
And I derive all the controllers from it.
In the Base Controller
I am overriding the OnAuthorization event handler to check for some stuff and then return true or false. If the result is true I want to redirect to the home page
protected override void OnAuthorization(AuthorizationContext filterContext)
{
if(CheckValues())
{
RedirectToHomePage();
}
}
public ActionResult RedirectToHomePage()
{
return RedirectToAction("Index", "Home");
}
The redirection is working for normal action calls.
But when there is an AJAX CALL the Home page is loading inside a DIV of the page and not as a new page.
Is there a way I can force the entire page to reload and redirect to the homepage when there is an AJAX Call?
I tried to use Redirect("~/") to redirect to the root URL but same issue. the page is loading inside the DIV and not in the entire page.
Hope I was clear. thanks a lot for any help
How are you doing your AJAX call? If you’re using jQuery AJAX then you can use the on success to redirect the page.