MVC Site - Ensuring the default entry view is always correct
I have a MVC site with AD authorization. This is all working fine. I publish the site to the webserver and call the site directly (http://intranet). If I have not logged in for a while (I have an authorised cookie with a 30 minute TTL), I am prompted to log-in and if successful I am redirec开发者_开发知识库ted to the homeController's index view. This is great and as expected.
If I keep the session open (browser open) and browse away from the site, if I then browse back to http://intranet, I am not challenged as I have recently authenticated but the default page is from a different controller and not the home page view.
How can I stop this from happening? It cannot be a session setting as this is not a new session and the routes appear correct - they are not beng called at this point anyhow.
Please MVC guru's advise....!
Register route block is as follows:
public static void RegisterRoutes(RouteCollection routes)
{
// standard MVC route regsitration
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"PaginatedTimesheets", // Route name
"{controller}/{action}/{page}/{view}", // URL with parameters
new { controller = "Timesheets", action = "Index", page=0, view=0 } // Parameter defaults
);
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = "" } // Parameter defaults
);
}
What is your default route look like? It should be going to your default controller/action specified in your routes.
Fixed with redirect
精彩评论