I'm having an issue with how to handle Bad Request (Error 400) in my MVC 4 application. I followed this article: http://www.digitallycreated.net/Blog/57/getting-the-correct-http-status-codes-out-of-asp.net-custom-error-pages to get my error pages setup to send the proper response codes. It works for all the codes I've tested so far (403, 404, and 500). But I'm having troubles with the 400 error code because I lose access to Session and User objects when the error is thrown. I am using Session and User to generate the menus (different users can see different menus depending on their role). So when I call to the menu controller to generate the menu, it throws a null ref exception because there isn't a Session or User object. I read that I don't have access to Session until after AcquireRequestState event is raised. So I suspect I haven't gotten there yet (how can I check this in debugger?). What other options do I have? I was thinking I could store the information in a cookie instead of the session, but I'd rather not...
Asked
Active
Viewed 333 times
1
-
A similar question was asked previously. http://stackoverflow.com/questions/7511239/asp-net-mvc-how-to-handle-400-bad-request-error-when-url-end-with – Vinod Aug 19 '13 at 20:09
-
According to my tests, that answer is wrong. I've got it to show a custom 400 page (with correct response code). But I can only generate the page if I don't use Session or User (because they are null). I have to set this in web.config `