Asp.Net MVC Identify Site via Url -
i have application support multiple sites. site determined based on url.
for example http://myapp/site/abc123/... , http://myapp/site/xyz123/...
the site code drive lot of functionality example themes, available modules, etc...
questions:
1-)i need validate site code valid , if isn't, should direct user info page. looking @ using irouteconstraint, appropriate? there other/better options?
2-)any gotchas approach (using url identify site)? there better approach?
solution
i ended creating custom actionfilter , check sitecode in onactionexecuting event. seems work , fit better irouteconstraint.
the system have implemented uses urls identify unique page content within single site , routing process pretty straightforward. being said, may want consider making use of areas in mvc application. areas can have multiple sections website have own mvc structure can run semi-independently.
essentially, have 1 base routing definition lays out defaults , rest of "sites" define own routes pointing controllers , views in separate location. it's pretty easy set up, you'll need make sure you're using version 2.0 of asp.net mvc. here's decent looking tutorial on asp.net mvc areas , routes. in current model mvc 2.0 supports you'll have single web project each area, not requirement. phil haacked has code asp.net mvc single project areas if you're looking example of technique, although you, personally, benefit more first article.
so long define routes have clear , measurable constraints, shouldn't have trouble laying out website you've described.
Comments
Post a Comment