Q:

MVC Exception to JavaScript Reroute

I need to create an exception that will reroute from my MVC view to a Login screen.
routes.MapMvcAttributeRoutes();
  routes.MapRoute(
    name: "Login",
    url: "{controller}/{action}/{id}",
    defaults: new {controller = "Account", action = "Login", id = UrlParameter.Optional }
  );

For some reason it can't be done in MVC when it's a javascript request.

A:

I think what @Gupta is trying to do is the following:
public class MyNewClass : MyBaseClass
{
    public MyExceptionClass() : base()
    {
        //other stuff here
    }
}

public class MyBaseClass : Controller {
  private bool isRoute;
  private bool isAuthenticated;

  MyBaseClass(){
    isReroute = MethodCheckReroute();
    isAuthenticated = MethodCheckAuth();

    if (isReroute || !isAuthenticated) {
      Response.RedirectToRoute("Login");
      throw new System.Web.Http.HttpResponseException(
      new HttpResponseMessage(HttpStatusCode.ExpectationFailed));
   }
}

