Showing posts with label web.config. Show all posts
Showing posts with label web.config. Show all posts

Tuesday 6 December 2016

Difference Between System.Web and System.WebServer



System.web is the settings section for IIS6 and the built in cassini server (the test server in Visual Studio 2010 and before where you are targeting asp.net 3.5 or lower)

The system.webserver is a child of the configuration section that means in web.config file <system.webserver> tag is placed under
<configuration> Tag.

System.WebServer Tag is contained in web.config file in root directory of website. This file contains configuration that needs to be implemented on IIS for Current project. Configuration coded in <system.webserver> Tag are implemented on IIS and are only applied to Project or Webapplication to which corresponding web.config Belongs. This Tag Can Exist is one of below formats in your project's web.config file in root directory of Web Application.

Empty <system.webserver> Tag Under <configuration> Tag -

<configuration>
  <system.webServer>
  </system.webServer>
</configuration>

The system.web section is used in web.config file of Asp.net WebApplications for defining Server Configuration that are applicable for IIS 6, while the system.webserver version is used to configure IIS 7.0. IIS 7.0 includes a new ASP.NET pipeline and some configuration differences. you can check complete details on link below -

https://msdn.microsoft.com/en-us/library/bb763179.aspx


System.webserver is the Server Configuration section for IIS 7 and above, and the build in IIS Express server which is used in Visual Studio 2010 targeting asp.net 4 and any newer versions that are released in the future.

Sample of Web.config file Contains Both <system.web> and <system.webserver>

<?xml version="1.0"?>
<!--
    Note: As an alternative to hand editing this file you can use the
    web admin tool to configure settings for your application. Use
    the Website->Asp.Net Configuration option in Visual Studio.
    A full list of settings and comments can be found in
    machine.config.comments usually located in
    \Windows\Microsoft.Net\Framework\v2.x\Config
-->
<configuration>
<appSettings>
<add key="username" value="admin-heemanshu@564496"/>
<add key="password" value="@htennty50!334#"/>
</appSettings>

<connectionStrings/>

<system.web>
<!--
            Set compilation debug="true" to insert debugging
            symbols into the compiled page. Because this
            affects performance, set this value to true only
            during development.

            Visual Basic options:
            Set strict="true" to disallow all data type conversions
            where data loss can occur.
            Set explicit="true" to force declaration of all variables.
        -->
<compilation debug="true" strict="false" explicit="true"/>
<pages>
<namespaces>
<clear/>
<add namespace="System"/>
<add namespace="System.Collections"/>
<add namespace="System.Collections.Specialized"/>
<add namespace="System.Configuration"/>
<add namespace="System.Text"/>
<add namespace="System.Text.RegularExpressions"/>
<add namespace="System.Web"/>
<add namespace="System.Web.Caching"/>
<add namespace="System.Web.SessionState"/>
<add namespace="System.Web.Security"/>
<add namespace="System.Web.Profile"/>
<add namespace="System.Web.UI"/>
<add namespace="System.Web.UI.WebControls"/>
<add namespace="System.Web.UI.WebControls.WebParts"/>
<add namespace="System.Web.UI.HtmlControls"/>
</namespaces>
</pages>

<!--
            The <authentication> section enables configuration
            of the security authentication mode used by
            ASP.NET to identify an incoming user.
               -->

<authentication mode="Windows"/>

<!--
            The <customErrors> section enables configuration
            of what to do if/when an unhandled error occurs
            during the execution of a request. Specifically,
            it enables developers to configure html error pages
            to be displayed in place of a error stack trace.-->
<customErrors mode="Off" defaultRedirect="GenericErrorPage.htm">
<error statusCode="404" redirect="FileNotFound.htm"/>
</customErrors>
</system.web>
 
      <system.webServer>
       <rewrite>
        <rules>
          <rule name="Redirect" patternSyntax="ECMAScript" stopProcessing="true">
            <match url=".*" />
            <conditions>
                <add input="{HTTP_HOST}" pattern="^xyz.com$" />
            </conditions>
            <action type="Redirect" url="http://www.xyz.com/{R:0}" />
         </rule>
       </rules>
     </rewrite>
    </system.webServer>

</configuration>