سؤال

ما هي هذه الصفحة؟ لدي إدخال في ملف التكوين ... هل هذا يسبب أي ضرر؟

  <customErrors mode="off" defaultRedirect="GenericErrorPage.htm">
            <error statusCode="403" redirect="NoAccess.htm" />
            <error statusCode="404" redirect="FileNotFound.htm" />
        </customErrors>

هو الخطأ أدناه من genericerrorpage.htm

Server Error in '/' Application.
--------------------------------------------------------------------------------

Runtime Error 
Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine. 

Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".


<!-- Web.Config Configuration File -->

<configuration>
    <system.web>
        <customErrors mode="Off"/>
    </system.web>
</configuration>


Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's <customErrors> configuration tag to point to a custom error page URL.


<!-- Web.Config Configuration File -->

<configuration>
    <system.web>
        <customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/>
    </system.web>
</configuration>
هل كانت مفيدة؟

المحلول

الملفات "genericerrorpage.htm" و "noaccess.htm" و "fileNotfound.htm" هي أسماء ملفات افتراضية ، تم إنشاؤها بواسطة Visual Studio عند إنشاء تطبيق ويب. يمكنك استخدام أي ملف HTML أو صفحة ASPX واستخدام هذا الاسم في web.config. هذه الأسماء هي مجرد قيم وهمية.

نصائح أخرى

في الأساس ، إذا حصل المستخدم على أي خطأ بخلاف 403 أو 404 (أبرزها بخلاف ذلك هو 500 تم إرسالها إذا كان هناك استثناء) سيتم إعادة توجيههم إلى تلك الصفحة ، والتي لن تكون موجودة (وإذا كنت في IIS7 خط أنابيب متكامل أو تم تعيين IIS6 Wildcard ، سيحصلون بعد ذلك على Looted to FileNotfound.htm - وإلا فإنهم سيشاهدون فقط 404 قياسيًا).

من المحتمل أن يكون من الجيد على الأقل إعطاء المستخدم "أوه لا! هناك شيء خاطئ!" صفحة.

في حالة حدوث خطأ وكان رمز الحالة مختلفًا عن 403 أو 404 ، فسيتم إعادة توجيهه إلى GenericErrorPage.htm

كما لديك خطأ في إعلانك. ال mode يجب أن تكون السمة Off بدلاً من off:

<customErrors mode="Off" defaultRedirect="GenericErrorPage.htm">
    <error statusCode="403" redirect="NoAccess.htm" />
    <error statusCode="404" redirect="FileNotFound.htm" />
</customErrors>
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top