Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6817221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:01:26+00:00 2026-05-26T21:01:26+00:00

This may be an odd situation but here is my current problem: I am

  • 0

This may be an odd situation but here is my current problem:

I am building an application which is environment driven(ie. Dev/Staging/Live)

So as a user comes to the app for their first time(myapp.local) and I process the default route:

        routes.MapRoute(
            "Default",
            "{controller}/{action}/{id}", 
            new { controller = "Home", environment = string.Empty, action = "Index", id = UrlParameter.Optional } 
        );

, it sure would be nice to add the environment to the url,
so that this:

        myapp.local

becomes this:

        myapp.local/environment/development

Is there a way to do this using C# Asp.Net MVC 2.0?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T21:01:27+00:00Added an answer on May 26, 2026 at 9:01 pm

    You could always add route tokens:

    routes.MapRoute(
        "Default",
        "environment/{env}/{controller}/{action}/{id}", 
        new { 
            controller = "Home", 
            env = "development", 
            action = "Index", 
            id = UrlParameter.Optional 
        } 
    );
    

    This being said adding the environment to your routes is a HORRIBLE idea. I sincerely hope you never do anything like this and that your controller actions would never ever looks anything like this:

    public ActionResult Index(string env)
    {
        string value = "default";
        if (env == "development")
        {
            value = "some value for dev";
        } 
        else if (env == "staging")
        {
            value = "some value for staging";
        }
        else if (env == "live")
        {
            value = "some value for live";
        }
        else
        {
            throw new Exception("Unknown environment");
        }
    
        ViewBag.Message = value;
        return View();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

OK, so this may be an odd situation but please bear with me. I
This may seem a bit odd, but I really need to create a workaround
I am still learning SQL so this may seem a very odd question, but
this may seem a little odd, but it would make for a convenient way
This may seem like an odd question, but I need to find a closed-source
This may seem like an odd question, but I have my own reasons for
Hi so this may sound odd but lets say currently I am doing this:
This may seem like an odd one, but I want to be able to
This may at first seem like an odd question, but when a cin request
Im aware this may be a slightly odd question, but given a Page class

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.