Frage

Wofür ist diese Seite? Ich habe einen Eintrag in der Konfigurationsdatei ... verursachen Sie dies Schaden?

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

Ist der folgende Fehler von 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>
War es hilfreich?

Lösung

Die Dateien 'GeneraCerrorPage.htm', 'noaccess.htm' und 'fileNotfound.htm' sind Standard -Dateinamen, die beim Erstellen einer Webanwendung von Visual Studio erstellt wurden. Sie können jede HTML -Datei oder ASPX -Seite verwenden und diesen Namen in web.config verwenden. Diese Namen sind nur Dummy -Werte.

Andere Tipps

Grundsätzlich, wenn ein Benutzer einen anderen Fehler als 403 oder 404 erhält (vor allem als diese, die 500 sind, wird er gesendet, wenn es eine Ausnahme gibt), werden er zu dieser Seite umgeleitet, die nicht existiert (und wenn Sie in IIS7 sind Integrierte Pipeline oder IIS6 Wildcard zugeordnet werden sie dann zum Filenotfound.htm abprallen - ansonsten sehen sie nur einen Standard 404).

Es wäre wahrscheinlich schön, dem Benutzer zumindest ein "Oh nein! Etwas stimmt nicht!" Seite.

Wenn ein Fehler auftritt und der Statuscode von 403 oder 404 unterscheidet GenericErrorPage.htm

Sie haben auch einen Fehler in Ihrer Erklärung. Das mode Attribut sollte sein Off Anstatt von off:

<customErrors mode="Off" defaultRedirect="GenericErrorPage.htm">
    <error statusCode="403" redirect="NoAccess.htm" />
    <error statusCode="404" redirect="FileNotFound.htm" />
</customErrors>
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top