Domanda

Sto sviluppando un'applicazione web utilizzando Umbraco. Creo un contenuto chiamato PageNotFound e, nella sezione errori di file di umbracoSettings.config, ho messo l'ID del nodo di quello per 404 error404. Il problema è che, con IIS 7, IIS sempre cerca la sezione httpErrors nel web.config e non lo fa prestare attenzione alla umbracoSettings.config.

Che cosa devo fare?

È stato utile?

Soluzione

Nel web.config (sezione system.webServer) si può dire al sito di passare tutta la gestione attraverso l'applicazione di errore:

<httpErrors existingResponse="PassThrough" />

Questo ha lo svantaggio che Umbraco non gestisce pagine tutt'altro che aspx che non si trovano.

Si potrebbe rendere meglio facendo qualcosa di simile, invece:

<httpErrors errorMode="Custom">
       <remove statusCode="404" subStatusCode="-1" />
       <error statusCode="404" prefixLanguageFilePath="" path="/non-existing-page.aspx" responseMode="ExecuteURL" />
</httpErrors>

La non-esistente-Page.aspx non esiste ancora in Umbraco, quindi si innesca un 404 (perché ha l'estensione aspx) e .. Presto! Umbraco gestisce il 404 perfettamente

Altri suggerimenti

I 500 errori non ha funzionato fino a quando ho aggiunto

existingResponse="Replace"

del genere

<httpErrors errorMode="Custom" existingResponse="Replace">
  <remove statusCode="404" subStatusCode="-1" />
  <remove statusCode="500" subStatusCode="-1" />
  <error statusCode="404" path="/non-existing-page.aspx" responseMode="ExecuteURL" />
  <error statusCode="500" path="error.html" responseMode="File" />
</httpErrors>
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top