Home > ASP.NET > Asp.net web.config differenze tra versione 3.5 e 4.5

Asp.net web.config differenze tra versione 3.5 e 4.5

Di seguito le modifiche ad un file web.config di asp.net versione 3.5 affinchè risulti compatibile con la versione 4.5 del framework di asp.net. In generale la versione 4.5 di asp.net è più snella molte dichiarazioni non sono più necessarie.

Nel primo file compatibile con il framework asp.net 3.5 sono evidenziate:

  • in rosso sezioni/righe  tipiche del framework 3.5 che vengono eliminate nel 4.5
  • in blue quelle modificate
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <configSections>
     <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
      <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
 <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
        <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
          <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere" />
          <section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
          <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
          <section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
        </sectionGroup>
      </sectionGroup>
    </sectionGroup>
  </configSections>
 <!-- application specific settings -->
 <appSettings>
    <add key="Server" value="192.168.1.157"/>
    <add key="DownloadareaMainPhysicalPath" value="G:\www\downloadarea" />
    ....      
 </appSettings>
 <system.webServer>
   <security>
     <requestFiltering allowDoubleEscaping="true" />
   </security>
     <modules>
        <remove name="ScriptModule" />
        <add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
     </modules>
     <handlers>
         <remove name="WebServiceHandlerFactory-Integrated" />
         <remove name="ScriptHandlerFactory" />
         <remove name="ScriptHandlerFactoryAppServices" />
         <remove name="ScriptResource" />
        <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add name="ScriptResource" verb="GET,HEAD" path="ScriptResource.axd" preCondition="integratedMode" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
 </handlers>
 </system.webServer>
 <system.web>
   <!-- globalization culture -->
   <globalization culture="it-IT" uiCulture="it-IT" requestEncoding="iso-8859-1" responseEncoding="iso-8859-1" />

 <sessionState timeout="15" />
 <!--
     Set compilation debug="true" to insert debugging
     symbols into the compiled page. Because this
     affects performance, set this value to true only
     during development.
 -->
 <compilation debug="true" defaultLanguage="c#">
    <assemblies>
       <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
       <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
       <add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
       <add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
    </assemblies>
  </compilation>
  <httpHandlers>
     <remove verb="*" path="*.asmx" />
     <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
     <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
     <add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false" />
  </httpHandlers>
  <httpModules>
         <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
  </httpModules>
 <!-- Portal supports either Forms authentication (Internet)
 or Windows authentication (for intranets). Forms Authentication is
 the default. To change to Windows authentication, comment the
 <authentication mode="Forms"> section below, and uncomment the
 <authentication mode="Windows"> section. -->
 <authentication mode="Forms">
    <!-- default timeout value 30 min (the timeout value is in minutes)-->
    <forms name=".ASPXFORMSAUTH" protection="All" timeout="60" />
    <!--forms name=".ASPXAUTH" protection="All" timeout="60" /-->
 </authentication>
 <!--<authentication mode="Windows" />
    <authorization>
    <deny users="?" />
 </authorization>-->

 <httpRuntime executionTimeout="500" maxRequestLength="10000" useFullyQualifiedRedirectUrl="true" />
 <urlMappings>
    <add url="~/AccessDenied.aspx" mappedUrl="~/portal.aspx?pg=access denied" />
    .... 
 </urlMappings>
 <customErrors mode="RemoteOnly">
     <error statusCode="405" redirect="~/portal.aspx?pg=HTTP 405" />
     <error statusCode="505" redirect="~/portal.aspx?pg=HTTP 505" />
     ...
 </customErrors>
 <pages validateRequest="false" enableViewStateMac="false" viewStateEncryptionMode="Auto">
    <namespaces>
       <add namespace="System.Globalization" />
       <add namespace="ASPNetPortal" />
       <add namespace="ASPNetPortal.Web.UI" />
    </namespaces>
    <controls>
       <add tagPrefix="ap" namespace="ASPNetPortal.Web.UI.WebControls" />
             <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
       <add namespace="AjaxControlToolkit" assembly="AjaxControlToolkit" tagPrefix="ajaxToolkit" />
            <add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    </controls>
 </pages>
 <!-- Adapter configuration for mobile controls used in the portal -->
 <mobileControls>
   <device name="PortalHtmlDeviceAdapters" inheritsFrom="HtmlDeviceAdapters">
      <control name="ASPNetPortal.MobileControls.TabbedPanel, Portal" adapter="ASPNetPortal.MobileControls.HtmlTabbedPanelAdapter,Portal" />
      <control name="ASPNetPortal.MobileControls.LinkCommand, Portal" adapter="ASPNetPortal.MobileControls.HtmlLinkCommandAdapter,Portal" />
   </device>
   <device name="PortalChtmlDeviceAdapters" inheritsFrom="ChtmlDeviceAdapters">
     <control name="ASPNetPortal.MobileControls.TabbedPanel, Portal" adapter="ASPNetPortal.MobileControls.ChtmlTabbedPanelAdapter,Portal" />
   </device>
   <device name="PortalWmlDeviceAdapters" inheritsFrom="WmlDeviceAdapters">
      <control name="ASPNetPortal.MobileControls.TabbedPanel, Portal" adapter="ASPNetPortal.MobileControls.WmlTabbedPanelAdapter,Portal" />
   </device>
 </mobileControls>
 <!-- Mobile device filters used for customizing portal -->
 <deviceFilters>
    <filter name="isJScript" compare="javascript" argument="true" />
    <filter name="isPocketIE" compare="browser" argument="Pocket IE" />
    <filter name="isHTML32" compare="preferredRenderingType" argument="html32" />
 </deviceFilters>
 </system.web>

 <location path="Admin">
   <system.web>
      <pages theme="ThAdmin" masterPageFile="~/TemplateAdmin.master" maintainScrollPositionOnPostBack="true"></pages>
   </system.web>
 </location>
 <location path="DesktopModules/EditMenu.aspx">
    <system.web>
       <pages theme="ThAdmin" masterPageFile="~/TemplateAdmin.master" maintainScrollPositionOnPostBack="true"></pages>
    </system.web>
 </location>
 ...
  
 <system.webServer>
 <directoryBrowse enabled="false" />
 <validation validateIntegratedModeConfiguration="false" />
 </system.webServer>
 <system.codedom>
   <compilers>
     <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CSharp.CSharpCodeProvider,System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="4">
          <providerOption name="CompilerVersion" value="v3.5" />
          <providerOption name="WarnAsError" value="false" />
     </compiler>
     <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="4">
          <providerOption name="CompilerVersion" value="v3.5" />
          <providerOption name="OptionInfer" value="true" />
          <providerOption name="WarnAsError" value="false" />
      </compiler>
   </compilers>
 </system.codedom>
 <runtime>
   <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1" appliesTo="v2.0.50727">
     <dependentAssembly>
        <assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0" />
     </dependentAssembly>
     <dependentAssembly>
        <assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0" />
     </dependentAssembly>
   </assemblyBinding>
 </runtime>
</configuration>


La versione 4.5 dello stesso web.config  decisamente più snella

<?xml version="1.0"?>
<configuration>

 <!-- application specific settings -->
 <appSettings>
    <add key="Server" value="192.168.1.157"/>
    <add key="DownloadareaMainPhysicalPath" value="G:\www\downloadarea" />
    ....      
 </appSettings>
 <system.webServer>
   <security>
     <requestFiltering allowDoubleEscaping="true" />
   </security>
 </system.webServer>
 <system.web>
   <!-- globalization culture -->
   <globalization culture="it-IT" uiCulture="it-IT" requestEncoding="iso-8859-1" responseEncoding="iso-8859-1" />

 <sessionState timeout="15" />
 <!--
     Set compilation debug="true" to insert debugging
     symbols into the compiled page. Because this
     affects performance, set this value to true only
     during development.
 -->
  <compilation debug="true" defaultLanguage="c#" targetFramework="4.5"/>
 <!-- Portal supports either Forms authentication (Internet)
 or Windows authentication (for intranets). Forms Authentication is
 the default. To change to Windows authentication, comment the
 <authentication mode="Forms"> section below, and uncomment the
 <authentication mode="Windows"> section. -->
 <authentication mode="Forms">
    <!-- default timeout value 30 min (the timeout value is in minutes)-->
    <forms name=".ASPXFORMSAUTH" protection="All" timeout="60" />
    <!--forms name=".ASPXAUTH" protection="All" timeout="60" /-->
 </authentication>
 <!--<authentication mode="Windows" />
    <authorization>
    <deny users="?" />
 </authorization>-->

 <httpRuntime executionTimeout="500" maxRequestLength="10000" useFullyQualifiedRedirectUrl="true" />
 <urlMappings>
    <add url="~/AccessDenied.aspx" mappedUrl="~/portal.aspx?pg=access denied" />
    .... 
 </urlMappings>
 <customErrors mode="RemoteOnly">
     <error statusCode="405" redirect="~/portal.aspx?pg=HTTP 405" />
     ...
 </customErrors>
 <pages validateRequest="false" enableViewStateMac="false" viewStateEncryptionMode="Auto" controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID">
     <namespaces>
       <add namespace="System.Globalization" />
       <add namespace="ASPNetPortal" />
       <add namespace="ASPNetPortal.Web.UI" />
    </namespaces>
    <controls>
       <add tagPrefix="ap" namespace="ASPNetPortal.Web.UI.WebControls" />
       <add namespace="AjaxControlToolkit" assembly="AjaxControlToolkit" tagPrefix="ajaxToolkit" />
    </controls>
 </pages>
 <!-- Adapter configuration for mobile controls used in the portal -->
 <mobileControls>
   <device name="PortalHtmlDeviceAdapters" inheritsFrom="HtmlDeviceAdapters">
      <control name="ASPNetPortal.MobileControls.TabbedPanel, Portal" adapter="ASPNetPortal.MobileControls.HtmlTabbedPanelAdapter,Portal" />
      <control name="ASPNetPortal.MobileControls.LinkCommand, Portal" adapter="ASPNetPortal.MobileControls.HtmlLinkCommandAdapter,Portal" />
   </device>
   <device name="PortalChtmlDeviceAdapters" inheritsFrom="ChtmlDeviceAdapters">
     <control name="ASPNetPortal.MobileControls.TabbedPanel, Portal" adapter="ASPNetPortal.MobileControls.ChtmlTabbedPanelAdapter,Portal" />
   </device>
   <device name="PortalWmlDeviceAdapters" inheritsFrom="WmlDeviceAdapters">
      <control name="ASPNetPortal.MobileControls.TabbedPanel, Portal" adapter="ASPNetPortal.MobileControls.WmlTabbedPanelAdapter,Portal" />
   </device>
 </mobileControls>
 <!-- Mobile device filters used for customizing portal -->
 <deviceFilters>
    <filter name="isJScript" compare="javascript" argument="true" />
    <filter name="isPocketIE" compare="browser" argument="Pocket IE" />
    <filter name="isHTML32" compare="preferredRenderingType" argument="html32" />
 </deviceFilters>
 </system.web>

 <location path="Admin">
   <system.web>
      <pages theme="ThAdmin" masterPageFile="~/TemplateAdmin.master" maintainScrollPositionOnPostBack="true"></pages>
   </system.web>
 </location>
 <location path="DesktopModules/EditMenu.aspx">
    <system.web>
       <pages theme="ThAdmin" masterPageFile="~/TemplateAdmin.master" maintainScrollPositionOnPostBack="true"></pages>
    </system.web>
 </location>
 ...
  
 <system.webServer>
 <directoryBrowse enabled="false" />
 <validation validateIntegratedModeConfiguration="false" />
 </system.webServer>
</configuration>


L

Annunci
  1. Non c'è ancora nessun commento.
  1. No trackbacks yet.

Rispondi

Inserisci i tuoi dati qui sotto o clicca su un'icona per effettuare l'accesso:

Logo WordPress.com

Stai commentando usando il tuo account WordPress.com. Chiudi sessione / Modifica )

Foto Twitter

Stai commentando usando il tuo account Twitter. Chiudi sessione / Modifica )

Foto di Facebook

Stai commentando usando il tuo account Facebook. Chiudi sessione / Modifica )

Google+ photo

Stai commentando usando il tuo account Google+. Chiudi sessione / Modifica )

Connessione a %s...

%d blogger hanno fatto clic su Mi Piace per questo: