Asp.Net MVC4 handeling错误HTTP400

时间:2017-08-30 11:56:36

标签: asp.net asp.net-mvc asp.net-mvc-4 web-config

可以任何身体帮助我,我尝试handel错误HTTP400,但它就像在Web.config,被忽略我有我的ErrorControler及其views.I做了web.config中的设置来处理错误......我需要别的东西吗?你知道为什么错误handeling不适用于任何错误吗? 这是我的web.config .....

<?xml version="1.0" encoding="utf-8"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
      <section name="IHMAzure.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
      <section name="Common.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
      <section name="DataAccess.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    </sectionGroup>
  </configSections>
  <connectionStrings>
    <!-- 
      [A MODIFIER]
      Chaîne de connexion à la base SECA1
    -->
    <add name="DataAccess.Properties.Settings.SECAConnexionString" connectionString="Data Source=vmdevmutsql40;Initial Catalog=SECA1_DEV01;" providerName="System.Data.SqlClient" />
  </connectionStrings>
  <appSettings>
    <add key="webpages:Version" value="2.0.0.0" />
    <add key="webpages:Enabled" value="false" />
    <add key="PreserveLoginUrl" value="true" />
    <add key="ClientValidationEnabled" value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />
  </appSettings>
  <system.web>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" enableVersionHeader="false"/>
    <!-- MRO - Désactivation du HTTP header X-AspNet-Version -->
    <!-- Authentification -->
    <roleManager enabled="true" />
    <authentication mode="Forms">
      <forms loginUrl="~/Account/Login" timeout="2880" />
    </authentication>


    <!-- fin Authentification -->

    <pages>
      <namespaces>
        <add namespace="System.Web.Helpers" />
        <add namespace="System.Web.Mvc" />
        <add namespace="System.Web.Mvc.Ajax" />
        <add namespace="System.Web.Mvc.Html" />
        <add namespace="System.Web.Optimization" />
        <add namespace="System.Web.Routing" />
        <add namespace="System.Web.WebPages" />
      </namespaces>
    </pages>
    <!--<customErrors defaultRedirect="~/Error/Index" mode="On" >
      <error statusCode="404" redirect="~/Error/NotFound"/>
      <error statusCode="403" redirect="~/Error/UnAuthorized" />

    </customErrors>-->
  </system.web>
  <system.webServer>

    <!---->
    <httpErrors errorMode="Custom" existingResponse="Replace">
      <clear />
      <error statusCode="400" responseMode="ExecuteURL" path="/Error/Index"/>
      <error statusCode="403" responseMode="ExecuteURL" path="/Error/UnAuthorized" />
      <error statusCode="404" responseMode="ExecuteURL" path="/Error/NotFound" />
      
    </httpErrors>
    <!---->
    <rewrite>
      <!-- MRO - Désactivation du HTTP header Server -->
      <outboundRules rewriteBeforeCache="true">
        <rule name="Remove Server header">
          <match serverVariable="RESPONSE_Server" pattern=".+" />
          <action type="Rewrite" value="-" />
        </rule>
      </outboundRules>
    </rewrite>
    <httpProtocol>
      <!-- MRO - Désactivation du HTTP header X-Powered-By -->
      <customHeaders>
        <remove name="X-Powered-By" />
      </customHeaders>
    </httpProtocol>

    <validation validateIntegratedModeConfiguration="false" />

    <handlers>

      <remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
      <remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
      <remove name="ExtensionlessUrlHandler-Integrated-4.0" />

      <add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
      <add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
      <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />

    </handlers>
  </system.webServer>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="DotNetOpenAuth.Core" publicKeyToken="2780ccd10d57b246" />
        <bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="DotNetOpenAuth.AspNet" publicKeyToken="2780ccd10d57b246" />
        <bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-1.3.0.0" newVersion="1.3.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0" />
      </dependentAssembly>

    </assemblyBinding>
  </runtime>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
  </entityFramework>
  <system.serviceModel>
    <bindings />
    <client />
  </system.serviceModel>

  <applicationSettings>

    <IHMAzure.Properties.Settings>
      <!--
        Période du planning en jour
      -->
      <setting name="PeriodePlanning" serializeAs="String">
        <value>30</value>
      </setting>
    </IHMAzure.Properties.Settings>
    <Common.Properties.Settings>

      <!--
        [A MODIFIER]
        Configuration du serveur SMTP : adresse et port
      -->
      <setting name="HostSMTP" serializeAs="String">
        <value>smtpapp.tf1.fr</value>
      </setting>
      <setting name="PortSMTP" serializeAs="String">
        <value>25</value>
      </setting>

      <!--
        [A MODIFIER]
        Email qui va envoyer les mails aux utilisateurs pour indiquer la création des comptes
        et les demandes de modification de mot de passe
      -->
      <setting name="NotificationSender" serializeAs="String">
        <value>noreply.secureaccess@tf1.fr</value>
      </setting>

      <!--
        [A MODIFIER]
        Identification et mot de passe du serveur SMTP.
        Si le serveur SMTP ne requière pas d'authentification, laisser vide
      -->
      <setting name="SMTPUsername" serializeAs="String">
        <value />
      </setting>
      <setting name="SMTPPassword" serializeAs="String">
        <value />
      </setting>
    </Common.Properties.Settings>
    <DataAccess.Properties.Settings>

      <!--
        [A MODIFIER]
        Identification et mot de passe pour se connecter à la base SecureAccess.
        Les deux sont cryptés avec l'outil de cryptage d'identstar.
        Possibilité de laiser vide, auquel cas utilisation d'integrated security=true
      -->
      <setting name="SECAUsername" serializeAs="String">
        <value></value>
      </setting>
      <setting name="SECAPassword" serializeAs="String">
        <value></value>
      </setting>
    </DataAccess.Properties.Settings>
  </applicationSettings>
</configuration>

0 个答案:

没有答案