url rewriting - IIS 7.5 URL rewrite module and URL routing in Global.asax for sub-applications -


i have "top-level" web-site, www.ccesd.ac.uk, , various "lower-level" web-sites running off such www.ccesd.ac.uk/britsocat separate sites share lot of code. these lower-level sites specified web applications in iis 7.5 , inherit common web.config file www.ccesd.ac.uk, although live in own application pools.

i have configured iis 7.5 url rewrite module lower-level sites can have own distinct urls, e.g. www.britsocat.com, maps www.ccesd.ac.uk/britsocat.

web-site configuration in iis 7.5

each site has own global.asax file url routing rules defined pretty urls. these urls (/home, /about, /contact etc.) common sites, including top-level (ccesd.ac.uk) site.

    void application_start(object sender, eventargs e)     {       // code runs on application startup       registerroutes(system.web.routing.routetable.routes);     }      // ** url routing **     private static void registerroutes(system.web.routing.routecollection routes)     {       routes.ignore("{resource}.axd/{*pathinfo}");       // home       routes.mappageroute("home", "home", "~/body.aspx", false, new system.web.routing.routevaluedictionary  { { "control", "homepage" } });       // contact       routes.mappageroute("contactus", "contact", "~/body.aspx", false, new system.web.routing.routevaluedictionary  { { "control", "ccesdcontactus" } });       //       routes.mappageroute("aboutus", "about", "~/body.aspx", false, new system.web.routing.routevaluedictionary  { { "control", "ccesdmissionstatement" } });     } 

i understand ruslan yakushev's excellent tutorial iis url rewriting module processed before asp.net routing in global.asax. way need work. however, if type www.britsocat.com/about, find global.asax file www.ccesd.ac.uk being used! (i have verified in testing.) furthermore, takes place before iis url rewriting. in other words, resulting page served www.ccesd.ac.uk/body.aspx?control=ccesdmissionstatement instead of www.ccesd.ac.uk/ britsocat /body.aspx?control=ccesdmissionstatement.

i suspect because have same routing rule ("about") in both sites (global.asax files). think fix changing name of rule in 1 of files; that's undesirable in general, "home".

is there i've missed or can fix it?

after lengthy conference msdn support team, appears cannot done: official response iis arr , url rewrite not designed used map separate domain names sub-applications in manner described above. ties in fact 1 can't bind separate domain name sub-application in iis, root-level web-site. officially recommended approach have separate web-sites in iis each distinct domain name (i.e. 1 britsocat.com, 1 ccesd.ac.uk etc.).

for interested, happening arr not aware of fact /britsocat sub-application of ccesd.ac.uk; once redirection (or rather, rewriting) had taken place, /britsocat treated standard virtual directory instead. once matching rule friendly url had been found in root-level global.asax file, no further searching took place , more specific /britsocat global.asax file ignored. (contrast situation without arr, sub-level global.asax file used in preference.) tried dodge moving routing rules various global.asax files init() methods of corresponding httpmodules instead, , having root-level web.config file specify root-level module , /britsocat web.config file specify own module (having first removed root-level module). result same, however; arr in use, sub-level web.config being ignored. (i tested putting non-existent module name in -- no error!) tried hacking root-level module ignored requests /britsocat address; since iis7, using "integrated mode" has consequence request information no longer available use in init() method of module (by design). finally, tried moving all routing rules iis (from global.asax); got me closer site still doing odd (and unexplained) things, , 7pm on friday before bank holiday weekend point, gave up.

my residual feeling 1 of mild disappointment: think limitation of iis arr/url rewriting should made clear , accounted for. msdn support admitted limitation felt justified in not explaining because seemed bizarre thing want -- them, separate domain name implies separate web-site, , sensible solution house them separate sites in iis , use virtual directories shared files , configuration settings. our point of view, have 1 principal site various "skins": each has own customisable style, appearance , features of them run same code base , use same config settings. therefore more natural design run them sub-directories in iis; , indeed works if don't try address them individually (i.e., separate domains). since commercial consideration (our clients require sites addressable choice of domain names) rather design consideration, seems ours in fact viable use-case has been missed.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

keyboard - C++ GetAsyncKeyState alternative -

android - java.net.UnknownHostException(Unable to resolve host “URL”: No address associated with hostname) -