O.O
O.O

Reputation: 11307

How to use URL routing with multiple environments?

I have three different environments that I need to be able to use url routing with:

  1. Debug
  2. Live
  3. Demo

The home pages for these three are:

  1. http://localhost:48060/Login.aspx
  2. http://192.168.0.145/Live/Login.aspx
  3. http://www.website.com/Demo/Login.aspx

Both Live and Demo sit in the same Default Web Site as web applications (live is exposed only internally, while demo is exposed externally).

I want to map these to

  1. http://localhost:48060/login
  2. http://192.168.0.145/Live/login
  3. http://www.website.com/Demo/login

Without triplicating every route mapping, what is the recommended approach?

Thanks!

Example of how I add the route for Debug env:

routes.MapPageRoute("Login", "login", "~/Views/Login.aspx");

More info:

When I tried adding

 routes.MapPageRoute("Login", "login", "~/Live/Views/Login.aspx");
 routes.MapPageRoute("Login", "login", "~/Demo/Views/Login.aspx");

the routes didn't work. I received a 404 error when trying visit http://192.168.0.145/Live/login Not sure what the problem is.

I'm using IIS 7.1 for published versions and whatever Win XP pro uses for debug.

Upvotes: 2

Views: 420

Answers (2)

O.O
O.O

Reputation: 11307

Turned out to be a configuration issue that m$ forgot to mention. Got it working by modifying my web.config to use runAllManagedModulesForAllRequests

  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true">

Upvotes: 1

ChevCast
ChevCast

Reputation: 59213

Youre "environments" seem to be sub-directories of the root of the application. Because the first of your three URLs does not contain a second value (e.g. "http://localhost:48060/debug/login") it's not going to be easy to define one route for all three.

If these secondary environments are defined as their own applications then you should be able to use the same route in each, but we would need more details to help you further.

Please describe your situation a little better and I will update my answer with more information.

Upvotes: 1

Related Questions