asp.net mvc - Multiple application root paths in one ASP MVC application -
my site structured pretty typically, paths like:
/home /home/search /categories /categories/misc what need happen have dynamic set of prefixes put on path , have map same place, , more importantly, have prefix kept throughout site. prefix won't there, when it's there, needs kept.
for example, want /client1/program1/home map same controller action/view /home, , if there's link on /home references url.content("~") or url.action("categories"), generated url needs keep /client1/program1 prefix of request, example in latter case: /client1/program1/categories. need prefix remain on every request maintain custom functionality specific client/program. typically manage sub-domains , dns, leaving paths alone, particular client has compliance problems running on multiple domains.
the /client1/ part static , can set in code, change infrequently, /program1/ part dynamic , need support changes there without deploying new code.
i've been trying working combination of url rewriting, routes, or custom virtualpathprovider, can't seem work. session , cookies aren't reliable enough, time out , can cleared. there many places change try consistently on query string.
url rewriting strips path info away before application can see it. still needs access read client , program should displaying.
routes can request right controller, subsequent requests page ignore whatever client/program was.
a custom virtualpathprovider feels promising direction, underlying physical path isn't changing. seems more useful having separate application in directory running in root of site. changing doesn't change route , path handling, alters ability of engine find views.
any suggestions?
edit: routes handle paths go through engine, things url.action() work okay routes. have other urls generated url.content(), that's question i'm asking: how can change ~ maps in url.content()? think that's why started looking @ virtualpathprovider i'm pretty sure not @ need. more focused on mapping local physical file paths.
i don't know if i'm missing (as seems trivial), tried on test project , worked fine.
add route config.
routes.maproute("custom", "client1/{program1}/{controller}/{action}"); then, can use httpcontext.request object find value of program1
let me know if works.
Comments
Post a Comment