As a currently logged in user, when I go to the website, I'm redirected to a page that's doesn't currently exist (it sends me to the view article page, but doesn't display anything as it doesn't have any query parameters). I've searched around and found https://stackoverflow.com/a/27054856/397186 but its from a couple years ago, so I don't know if a better approach exists using Identity 2.0.
The question is: How can I redirect currently logged in users to the home page when they go to the website?
UPDATE 2016-10-08
Here are some screen shots showing the error: https://drive.google.com/drive/folders/0B5GjmejMcNuCM3RHNXBlbGNKYWs?usp=sharing
I really don't want to go with the Session_Start method. Let's say I've bookmarked a page on the site, and when they click on that bookmark it takes them to the home page. Not very friendly.
This web app uses MVC 5.
Thank you!
So, this is an MVC application.
Go to App_Start\RouteConfig.cs
or try to find another place where RegisterRoutes() is implemented.
Show us what this function looks like.
It should look something like:
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
Important is the part after "defaults". This should contain "Home", "Index" and not some other information
Also check that RegisterRoutes()
is actually executed. It should be called from Application_Start()
in your Global.asax.cs
file.