How to adjust asp.net URL routing based on domain/host?

Posted by DrewF on Stack Overflow See other posts from Stack Overflow or by DrewF
Published on 2010-05-08T23:25:15Z Indexed on 2010/05/08 23:28 UTC
Read the original article Hit count: 237

Filed under:
|
|

What's the best way to adjust the path destination for a routing table created in the global.asax Application_Start event based on the domain/sub domain/host? The following worked in IIS6, but with IIS7 the request object is decoupled from the Application_Start event and therefore does not work anymore:

Dim strHost As String = Context.Request.Url.Host  
Dim strDir As String = ""  
If strHost.Contains("domain1.com") Then  
    strDir = "area1/"  
Else  
    strDir = "area2/"  
End If  
routes.MapPageRoute("Search", "Search", "~/" & strDir & "search.aspx") 

© Stack Overflow or respective owner

Related posts about iis7

Related posts about ASP.NET