Reputation: 9489
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.
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?
Upvotes: 0
Views: 238
Reputation: 131
"ConfigurationManager" looks at "Web.Config" for ASP.Net solutions, so you can find it either in:
<configuration>
<appSettings>
<add key="IsTesting" value="true"/>
</appSettings>
</configuration>
Or if you access the IIS Manager and select the website then click on "Application Settings" you can change it through a GUI.
Upvotes: 1
Reputation: 3526
Inside the <configuration>
element in your App/Web.config file, there should be (or you should create) a <appSettings></appSettings>
tag, and the individual settings look a bit like this:
<appSettings>
<add key="NewKey0" value="Something1" />
<add key="NewKey1" value="Something2" />
</appSettings>
Upvotes: 1