2011-05-23 16 views
11

मैं कस्टम त्रुटि पृष्ठों के साथ एक नई साइट बना रहा हूं। मैंने अपना web.config सेटअप किया है, और मेरे सभी पेज सेटअप हैं।आईआईएस 7 वेब सर्वर कस्टम त्रुटियां - स्थानीय पर काम करती है लेकिन उत्पादन के लिए प्रकाशित नहीं होने पर

जब मैं स्थानीय रूप से चलाता हूं, और त्रुटियों को बल देता हूं (पृष्ठ नहीं मिला आसान है), यह सब ठीक काम करता है। लेकिन जब मैं अपने विंडोज सर्वर 2008 आर 2 उत्पादन सर्वर पर प्रकाशित करता हूं, और एक खराब पृष्ठ दर्ज करता हूं, तो यह मुझे अभी भी डिफ़ॉल्ट IIS7 त्रुटि पृष्ठ पर ले जाता है।

यहाँ मेरी web.config से एक नमूना है (और अपने पृष्ठों सब वहाँ हैं):

<?xml version="1.0"?> 
<!-- 
    For more information on how to configure your ASP.NET application, please visit 
    http://go.microsoft.com/fwlink/?LinkId=169433 
    --> 
<configuration> 
    <system.web> 
     <compilation debug="true" targetFramework="4.0"/> 
    <customErrors mode="On" defaultRedirect="~/ErrorGeneral"> 
     <error statusCode="400" redirect="~/ErrorBadRequest" /> 
     <error statusCode="401" redirect="~/ErrorUnathorized" /> 
     <error statusCode="402" redirect="~/ErrorPaymentRequired" /> 
     <error statusCode="403" redirect="~/ErrorForbidden" /> 
     <error statusCode="404" redirect="~/ErrorItemNotFound" /> 
     <error statusCode="405" redirect="~/ErrorMethodNotAllowed" /> 
     <error statusCode="406" redirect="~/ErrorNotAcceptable" /> 
     <error statusCode="412" redirect="~/ErrorPreconditionFailed" /> 
     <error statusCode="500" redirect="~/ErrorInternalServerError" /> 
     <error statusCode="501" redirect="~/ErrorNotImplemented" /> 
     <error statusCode="502" redirect="~/ErrorBadGateway" /> 
    </customErrors> 
    </system.web> 
</configuration> 

मैं गलत तरीके से कुछ सरल कर रहा हूं? क्या यह विंडोज सर्वर 2008 आर 2 के साथ एक अंतर है?

संपादित करें:

<?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> 
    <system.web> 
     <compilation debug="true" targetFramework="4.0" /> 
    <customErrors mode="On" defaultRedirect="~/ErrorGeneral"> 
     <error statusCode="400" redirect="~/ErrorBadRequest" /> 
     <error statusCode="401" redirect="~/ErrorUnathorized" /> 
     <error statusCode="402" redirect="~/ErrorPaymentRequired" /> 
     <error statusCode="403" redirect="~/ErrorForbidden" /> 
     <error statusCode="404" redirect="~/ErrorItemNotFound" /> 
     <error statusCode="405" redirect="~/ErrorMethodNotAllowed" /> 
     <error statusCode="406" redirect="~/ErrorNotAcceptable" /> 
     <error statusCode="412" redirect="~/ErrorPreconditionFailed" /> 
     <error statusCode="500" redirect="~/ErrorInternalServerError" /> 
     <error statusCode="501" redirect="~/ErrorNotImplemented" /> 
     <error statusCode="502" redirect="~/ErrorBadGateway" /> 
    </customErrors> 
    </system.web> 
    <system.webServer> 
     <httpErrors> 
      <remove statusCode="502" subStatusCode="-1" /> 
      <remove statusCode="501" subStatusCode="-1" /> 
      <remove statusCode="500" subStatusCode="-1" /> 
      <remove statusCode="412" subStatusCode="-1" /> 
      <remove statusCode="406" subStatusCode="-1" /> 
      <remove statusCode="405" subStatusCode="-1" /> 
      <remove statusCode="403" subStatusCode="-1" /> 
      <remove statusCode="401" subStatusCode="-1" /> 
      <remove statusCode="404" subStatusCode="-1" /> 
      <error statusCode="404" prefixLanguageFilePath="" path="/Pages/ErrorItemNotFound.aspx" responseMode="ExecuteURL" /> 
      <error statusCode="401" prefixLanguageFilePath="" path="/Pages/ErrorUnauthorized.aspx" responseMode="ExecuteURL" /> 
      <error statusCode="403" prefixLanguageFilePath="" path="/Pages/ErrorForbidden.aspx" responseMode="ExecuteURL" /> 
      <error statusCode="405" prefixLanguageFilePath="" path="/Pages/ErrorMethodNotAllowed.aspx" responseMode="ExecuteURL" /> 
      <error statusCode="406" prefixLanguageFilePath="" path="/Pages/ErrorNotAcceptable.aspx" responseMode="ExecuteURL" /> 
      <error statusCode="412" prefixLanguageFilePath="" path="/Pages/ErrorPreconditionFailed.aspx" responseMode="ExecuteURL" /> 
      <error statusCode="500" prefixLanguageFilePath="" path="/Pages/ErrorInternalServerError.aspx" responseMode="ExecuteURL" /> 
      <error statusCode="501" prefixLanguageFilePath="" path="/Pages/ErrorNotImplemented.aspx" responseMode="ExecuteURL" /> 
      <error statusCode="502" prefixLanguageFilePath="" path="/Pages/ErrorBadGateway.aspx" responseMode="ExecuteURL" /> 
     </httpErrors> 
    </system.webServer> 
</configuration> 

उत्तर

19

डिफ़ॉल्ट रूप से IIS7 HTTP स्थिति कोड जैसे कि 4xx और 5xx को पाइपलाइन को आगे बढ़ाकर अनुप्रयोगों द्वारा उत्पन्न करता है।

आप आईआईएस बता सिर्फ अपने त्रुटि पृष्ठ और इसकी जगह के बिना मौजूदा प्रतिक्रिया के माध्यम से पारित करने के लिए कर सकते हैं: देख

<configuration> 
    <system.webServer> 
    <httpErrors existingResponse="PassThrough" /> 
    </system.webServer> 
</configuration> 

अधिक जानकारी के लिए:

HTTP Errors <httpErrors>

0

इस help करता है: मैं इस मुद्दे को, जो web.config फ़ाइल में अतिरिक्त जानकारी है, इस तरह देखने के लिए मिल गया?

मुझे आश्चर्य है कि आपको रास्ते में कस्टम त्रुटियों के रास्ते भी पंजीकृत करना होगा।

संबंधित मुद्दे