0

My login page is http://localhost/account/login. After user login, I intend to classify the user based on group.

Group 1 will have

http://localhost/group1/home/index

Group 2 will have

http://localhost/group2/home/index

Just point me into a right direction, is it involve Mvc.Area? Sorry totally new to MVC.

dausdashsan
  • 241
  • 1
  • 6
  • 16
  • You can use a similar method to [this answer](https://stackoverflow.com/a/37022067/181087) to redirect a user to a specific URL after logging in and back to a general URL after logging out. You *could* use Areas, but it is unclear from your question whether the actions will be the same or different for each group. If they are all exactly the same, you could accomplish everything you need with routing. If not, then Areas (or alternatively, [MvcCodeRouting](http://mvccoderouting.codeplex.com/)) would be a better choice. – NightOwl888 Jun 14 '16 at 13:28

1 Answers1

0

Try This

Change the App_Start/RouteConfig.cs

 public class RouteConfig
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");     

            routes.MapMvcAttributeRoutes();//You Can Add Manually  

            routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
            );
        }
    }

then yo can modify Controller

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace WebApplication1.Controllers
{
    public class HomeController : Controller
    {
        // GET: Home
        public ActionResult Index()
        {
            return View();
        }
        // http://localhost:52603/group1/home/index
        [Route("group1/home/index")]
        public ActionResult Group1()
        {
            return View();
        }
        //http://localhost:52603/group2/home/index
        [Route("group2/home/index")]
        public ActionResult Group2()
        {
            return View();
        }
    }
}