Giter VIP home page Giter VIP logo

Comments (3)

iaingalloway avatar iaingalloway commented on August 18, 2024 1

I'm not sure I understand what your expected behaviour is here. The error controller isn't intended to be invoked directly via the default route. It replaces the original response as per the settings in the web.config.

The example links on the index don't refer to the error controller by its route, but instead simulate actual error conditions in your application (by raising an exception for 500, setting a status code for 403, and not existing at all for 404).

If for some reason you want to be able to call the the Other action on the Errors controller like "Errors/Other/400" then sure you'll need to either rename the parameter, or alter the routes - but that's not really the purpose of this demo.

As a tangent, if for some reason you do call the error controller directly, then the error replacement configured in the web.config still happens. For example, if you e.g. call http://httperrors-example.azurewebsites.net/Errors/Other/?code=403 - the 403 status code set by the controller gets (correctly) intercepted by IIS and the /Error/Forbidden action is rendered instead.

from asp.net-httperrors-example.

iokevins avatar iokevins commented on August 18, 2024

Hi Iain,

Thank you; after reading your response, I find myself in complete agreement and with an even better understanding of how it works--e.g., /Errors/Other/?code=403 > /Error/Forbidden > /Errors/Forbidden.

Looking back, my issue does seem worded rather confusingly--it arises after a day or two of wrestling with two implementation issues:

  1. In my case, I had to change web.config path, from path="/Error/Forbidden" to path="/MyAppFolder/Error/Forbidden" (that is, rooted to web site, not web app subfolder)...otherwise I got empty/blank screen content with 403 forbidden or 404 not found errors

  2. The above confusion (on my part) about directly accessing controllers

Now I have resolved those issues and wanted to share what worked for me, so others might also use this solution successfully.

I'm grateful. Thank you again.

Kevin

from asp.net-httperrors-example.

iaingalloway avatar iaingalloway commented on August 18, 2024

Great! Glad you got sorted!

from asp.net-httperrors-example.

Related Issues (2)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.