I inherited a vb.net WebForms project that handles a couple domains. However, I want unique routes for each domain. Is there a way to do this by getting the domain when I use MapPageRoute? Or will I need to do something like:
routes.MapPageRoute("r1", "example1/page1", "~/example1/default.aspx")
routes.MapPageRoute("r2", "example2/page1", "~/example2/default.aspx")
But then the urls will need to be like:
//example1.com/example1/page1 and //example2.com/example2/page1
At Application_Start, I'd like to constrain a route to a specific domain, if possible.
* EDIT *
Ok, it looks like I was able to semi-resolve this by creating unique route names for similar route paths:
routes.MapPageRoute("r1", "page1", "~/example1/default.aspx")
routes.MapPageRoute("r2", "page1", "~/example2/default.aspx")
Then in my markup I can do:
<asp:HyperLink NavigateUrl="<%$RouteUrl:routename=r1%>" ID="link_home" runat="server">Home</asp:HyperLink>
Then in my Default page (or its master page), I can then handle the "//example.com/" request by redirecting to the respective route based on the domain.
However I'm not sure how to handle incoming requests like:
//example1.com/page1 and //example2.com/page1. I assume the first route will load for either domain. Any ideas what I can do?