Upon login I want to re route to a new page. (Example: mysite.com/Dashboard/User/Username)
I also want it to verify that user is logged in before it allows access to said URL.
I'm new to MVC and C# and appreciate your help.
My controller: What do I pass into the controller to make it work?
public class DashboardController : Controller
{
// GET: Dashboard
public ActionResult User()
{
return View();
}
}
Route.config.cs:
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
routes.MapRoute(
name: "UserNameRoute",
url: "{username}",
defaults: new { controller = "Dashboard", action = "User", username = "" }
);
}
}