मुझे http://blogs.msdn.com/b/webdev/archive/2013/11/22/debugging-owin-app-or-framework.aspx से डेमो कोड मिला, और यह एक सेक्सी त्रुटि पृष्ठ दिखाता है।माइक्रोसॉफ्ट द्वारा किस प्रकार के अपवाद पकड़े जाएंगे। ओविन.डिग्नोस्टिक्स.इररपेज एक्सटेंशन। यूसरररपेज
app.UseErrorPage(new ErrorPageOptions()
{
//Shows the OWIN environment dictionary keys and values. This detail is enabled by default if you are running your app from VS unless disabled in code.
ShowEnvironment = true,
//Hides cookie details
ShowCookies = false,
//Shows the lines of code throwing this exception. This detail is enabled by default if you are running your app from VS unless disabled in code.
ShowSourceCode = true,
});
app.Run(async context =>
{
throw new Exception("UseErrorPage() demo");
await context.Response.WriteAsync("Error page demo");
});
}
हालांकि, अगर मैं एक नियंत्रक कार्रवाई में एक अपवाद फेंक, त्रुटि पृष्ठ नहीं दिखाया जाएगा, और मैं अभी भी YSOD देखते हैं।
तो मैं जानना चाहता हूं कि UseErrorPage द्वारा कौन से अपवाद पकड़े जाएंगे? क्या इसे काम करने के लिए मुझे अतिरिक्त विन्यास की आवश्यकता है?
वेब एपीआई अपवाद को संभालने और इसे 500 प्रतिक्रिया में परिवर्तित करने के लिए उपयोग करता है इससे पहले कि UseErroPage मिडलवेयर इसे संभाल सके। आम तौर पर पाइपलाइन में किसी भी अनचाहे प्रतिक्रिया को UseErrorPage मिडलवेयर द्वारा नियंत्रित किया जाता है। – Praburaj