I have a website, xyz.com and users are setting up admin accounts where they then have other users that are registering under them. They call their account name wisconsinsponsor
. Another user sets up another account called iowasponsor
. So I want to be able to have the ability that a user could browse to xyz.com/wisconsinsponsor
and xyz.com/iowasponsor
and get funneled into the appropriate settings that these users have setup.
So then after I browse to xyz.com/wisconsinsponsor
which will allow me to get the appropriate settings for wisconsinsponsor I can be dropped onto xyz.com/wisconsinsponsor/{controller}/{method}
.
So I added the following code.
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
List<Sponsor> sponsors = new SponsorContext().Sponsors.ToList();
foreach (Sponsor sponsor in sponsors)
{
// ALL THE PROPERTIES:
// rentalProperties/
routes.MapRoute(
name: sponsor.SponsorName,
url: sponsor.SponsorName + "{controller}/{action}/{id}",
defaults: new
{
controller = "Home",
action = "Index",
id = sponsor.SponsorId
}
);
}
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new {
controller = "Home",
action = "Index",
id = UrlParameter.Optional }
);
}
So the main goal is that without logging in, I can get information that pertains to each "sponsor" and then just generic information if a user goes to 'xyz.com' without specifying a sponsor. The below works to a point for landing on the home page, but then when I navigate to login or any other view, I get for example 'xyz.com/[my first sponsor entry in the database]/admin/login' instead of 'xyz.com/admin/login'. Why doesn't the navigation fall to the Default route?