Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
615 views
in Technique[技术] by (71.8m points)

.net - Setting errorPage in Umbraco

I am developing a web application using Umbraco. I create a content called PageNotFound and, in the errors section of umbracoSettings.config file, I put the node id of that for 404 error404. The problem is that, with IIS 7, IIS always looks for the HttpErrors section in web.config and does not pay attention to umbracoSettings.config.

What should I do?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

In your web.config (system.webServer section) you can tell the site to pass all of the error handling through to the application:

<httpErrors existingResponse="PassThrough" />

This has the disadvantage that Umbraco doesn't handle anything but .aspx pages that are not found.

You could make it better by doing something like this instead:

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

The non-existing-page.aspx does not exist yet in Umbraco, so it triggers a 404 (because it has the aspx extension) and.. presto: Umbraco handles the 404 perfectly!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...