SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Enthusiast xarzu's Avatar
    Join Date
    Apr 2007
    Posts
    73
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    What is the Congiguration manager class in the code and how to you set it in the Proj

    What is the Congiguration manager class in the code and how to you set it in the Project or IDE?

    How do I set AppSettings in an ASPX project's Configuration manager?

    This is an ASPX/CS Project with Visual Studio 2010. It is a Configuration Manager question.

    I am successfully debugging (sort of) some code that is being used already on a server. But there is a piece of code that plays with the URL in the live version that should not be used in the debug/localhost version.

    Code:
         protected void Page_Load(object sender, EventArgs e)
            {
                if (ConfigurationManager.AppSettings["IsTesting"] == "false" && Request.Url.ToString().Contains("http:"))
                {
                    Response.Redirect(Request.Url.ToString().Replace("http:", "https:"));
                }
    
                LoadMasterTemplate();
            }
    This piece of code lands on the "Response.Redirect...." line when it should not because the "IsTesting" app setting should be set to true in the ConfigurationManager . How do I set that?

  2. #2
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,214
    Mentioned
    153 Post(s)
    Tagged
    0 Thread(s)
    Edit your web.config of the project or your machine level web.config

    There is an appSettings section, and inside that section should be <add key="IsTesting" value="false" /> you will want to set it to true.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •