Team LiB
Previous Section Next Section

ASP.NET Configuration

There are two files that you can use to control ASP.NET pages:

To make matters even muddier, you can place Web.config files in each folder or virtual directory of your site, and those settings will override settings in higher Web.config files.

Configuration File Elements

There are many elements that can be added to the System.Web section of your configuration files, as shown in Table 23-4.

Table 23-4: Configuration File System, Web Section Elements

Element

Description

trace

Controls page and application tracing

globalizations

Specifies character encodings to use with requests and responses

httpRunTime

Specifies the maximum time a page can execute, the maximum size of a request, and if fully qualified names should be used for client redirects

compilation

Specifies the default programming language for pages, whether a page is compiled in debug mode or release mode, and the assemblies available to the application

pages

Specifies configuration information for a page

customErrors

Determines how errors are displayed

authentication

Specifies authentication settings

identity

Configures user account settings for impersonation

authorization

Determines the users and roles that can access pages

machineKey

Used to share encryption key information across a Web farm

trust

Sets security policy settings

securityPolicy

Contains a list of security policies

sessionState

Sets session state information such as in-process, out-of-process, or cookieless

httpHandlers

Associates a particular HTTP handler with a specific page path and request verb

httpModules

Lists the modules involved in page requests

processModel

Contains process-wide settings that control the aspnet _ wp processes

webControls

Sets the location of client-side scripts used with Web controls clientTarget

Lists values that are used by the ClientTarget property

browserCaps

Lists information about the capabilities of individual browser types

webServices

Configures settings for Web Services

The Web.config file provides for a Location property, which lets you set specific pages or specific paths.

<configuration>
              <location path="MyVirtualDirectory">
                        <system.web>
                        </system.web>
              </location>
              <location path="MyPage.aspx" allowOverrides="false">
                        <system.web>
                        </system.web>
              </location>
</configuration>

Configuration Attributes

You can set various attributes for the configuration file elements. Tables 23-5 through 23-8 show the attributes for the node, httpRuntime, processModel, and trace elements.

Table 23-5: Authentication Attributes for the Node Element

Value

Description

Windows

Uses credentials provided by IIS. The authorization element can be used to control access further.

Forms

Provides for custom authorization.

Passport

Allows for the use of passport authentication.

None

Disables authentication at the ASP.NET level.

Table 23-6: httpRuntime Attributes

Attributes

Description

appRequestQueueLimit

Specifies the limit for request queuing.

Once this limit is reached, the server returns 503 errors. The default value is 100.

executionTimeout

Sets the amount of time that a request can execute before timing out. The default is 90 seconds.

MaxRequestLength

Sets the maximum file size that can be uploaded. The default value is 4KB. This is primarily used to prevent denial-of-service attacks.

MinFreeLocalRequestFreeThreads

Sets the minimum number of threads reserved for local requests. The default is 4.

minFreeThreads

Sets the minimum number of threads reserved for requests that require additional threads. The default is 8.

useFullyQualifiedRedirectUrl

Determines if URLs sent to the client are fully qualified or relative.

Table 23-7: processModel Attributes

Attribute

Description

Enable

Determines if process model settings are used.

Timeout

Sets the lifespan of the process. The default level is infinite.

idleTimeout

Sets the lifespan of an aspnet_wp process when idle. The default is infinite.

shutdownTimeout

Sets the amount of time the process can be shut down gracefully. The default is 5 seconds.

requestLimit

Sets the number of requests that can be processed by ASP.NET before it is shut down. The default is infinite.

requestQueueLimit

Sets the number of requests that can be queued before the process is shut down. The default is 50000.

memoryLimit

Sets the amount of memory that can be used by the aspnet_wp process before it will be recycled. The default is 60 percent.

cpuMask

Used in a Web garden where aspnet_wp affinity is set on processors.

webGarden

Enables Web gardening.

Username

Sets the username that an aspnet_wp process runs under.

comAuthenticationLevel

Sets the DCOM authentication level.

comImpersonationLevel

Sets the DCOM impersonation level.

responseRestartDeadlockInterval

Sets the amount of time that will be allowed between process restarts due to deadlocking. The default is 9 minutes.

responseDeadlockInterval

Sets the amount of time allowed without a response when requests are queued. The default is 3 minutes.

maxWorkerThreads

Sets the maximum limit of worker threads per CPU in the thread pool.

maxIoThreads

Set the maximum limit on the number of IO threads per processor.

Table 23-8: Trace Attributes

Attribute

Description

Enabled

Enables tracing. The default is false.

localOnly

Determines if tracing can be viewed remotely. The default is true.

pageOutput

Sets whether trace output is rendered at the bottom of the page or available via trace.axd. The default is false.

requestLimit

Sets the number of traces that can be stored in the trace buffer and be viewed by trace.axd. The default is 10.

traceMode

Sets the sort order of trace items. The default is SortByTime.

AppSettings Configurations

You can add your own custom settings by using the appSettings elements. To do this, configure your Web.config file as follows:

<configuration>
              <appSettings>
                        <add key="MyName" value="Greg MacBeth" />
              </appSettings>
</configuration>

You can read these settings with the following code:

string Name = ConfigurationSettings.AppSettings("MyName");

Important HTTP Classes

There are two important HTTP classes. One handles responses, and the other handles requests.

  • HttpRequest allows the gathering of data from the Web client. For example, you can get the authentication method, hostname, and address.

  • HttpResponse exposes data that will be sent to the client browser.


Team LiB
Previous Section Next Section