Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I determine the following default web config values?

I've been getting "Connection forcibly closed" errors and in researching a resolution, I have seen suggestions to money with the following web.config options, which currently are not set in my web app.

Before I change them, I'd like to know what they are currently set to.

Can someone tell me how to read these values from .NET code, preferably VB.NET, though C# is fine.

<httpRuntime 
executionTimeout="90" 
maxRequestLength="4096"
useFullyQualifiedRedirectUrl="false" 
minFreeThreads="8" 
minLocalRequestFreeThreads="4"
appRequestQueueLimit="100"
/>
like image 990
Chad Avatar asked May 18 '10 16:05

Chad


People also ask

What is Web config in C#?

A configuration file (web. config) is used to manage various settings that define a website. The settings are stored in XML files that are separate from your application code. In this way you can configure settings independently from your code. Generally a website contains a single Web.


1 Answers

Here is the MSDN Page that list what each value is and its default.

The following code will open the httpRuntime section programitcly

Configuration config = WebConfigurationManager.OpenWebConfiguration("~");
object o = config.GetSection("system.web/httpRuntime");
HttpRuntimeSection section = o as HttpRuntimeSection;

This code was found here

And in VB

Dim config As Configuration = WebConfigurationManager.OpenWebConfiguration("~")
Dim o As Object = config.GetSection("system.web/httpRuntime")
Dim section As HttpRuntimeSection = TryCast(o, HttpRuntimeSection)

Make sure you are using/Importing the following namespaces.

System.Configuration;
System.Web.Configuration;

Edit based on comment.

When calling WebConfigurationManager.OpenWebConfiguration From MSDN

path Type: System.String The virtual path to the configuration file. If null, the root Web.config file is opened.

Even if you do not have httpRuntime defined in your web.config it is the root Web.config, and that is returned. I have tested this with and without httpRuntime defined.

like image 62
David Basarab Avatar answered Oct 12 '22 06:10

David Basarab