asp.net - Routes for multiple users -


i have website, xyz.com , users setting admin accounts have other users registering under them. call account name wisconsinsponsor. user sets account called iowasponsor. want able have ability user browse xyz.com/wisconsinsponsor , xyz.com/iowasponsor , funneled appropriate settings these users have setup.

so after browse xyz.com/wisconsinsponsor allow me appropriate settings wisconsinsponsor can dropped onto xyz.com/wisconsinsponsor/{controller}/{method}.

so added 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)     {         // 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 main goal without logging in, can information pertains each "sponsor" , generic information if user goes 'xyz.com' without specifying sponsor. below works point landing on home page, when navigate login or other view, example 'xyz.com/[my first sponsor entry in database]/admin/login' instead of 'xyz.com/admin/login'. why doesn't navigation fall default route?

you reverse variable in url.

xyz.com/{adminaccountvariable}/{controller}/{method}

using system; using system.collections.generic; using system.linq; using system.web; using system.web.mvc; using system.web.routing; namespace example {     public class routeconfig     {         public static void registerroutes(routecollection routes)         {             routes.ignoreroute("{resource}.axd/{*pathinfo}");              routes.maproute(                 name: "admin",                 url: "{id}/routingconstraintexample/{action}/",                 defaults: new { controller = "routingconstraintexample", action = "index", id = 0 },                 constraints: new { id = @"\d+" }             );              routes.maproute(                 name: "default",                 url: "{controller}/{action}/{id}",                 defaults: new { controller = "home", action = "index", id = 0 },                 constraints: new { id = @"\d+" }             );          }     } } 

this how think problem should handled.

owin more recent form of authentication. use security restrict access admin pages. owin or other forms of security can used identify user logged in. use identified user control settings used in admin pages.

http://www.asp.net/aspnet/overview/owin-and-katana/an-overview-of-project-katana

http://www.asp.net/vnext/overview/owin-and-katana

use database save admin user profile settings. work keeping track of profile subtypes similar adminaccount , admin2account shown in original question. controller , action same application know parts of view show based on if database returned adminaccount type or admin2account type person logged website.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -