Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
Radu - Adrian BuhaCourses Plus Student 5,535 Points
System.NullReferenceException shows in Browser not in Visual Studio. What can I do to change that?
So, as the tittle says, my System.NullReferenceException shows inside the browser, and the Visual Studio works just fine ( I mean, it doesn't shows me any errors), therefore I cannot "trace" the error using the "Autos" window as James does. Any ideea on how to change this? Thanks
Allan Clark10,810 Points
Without seeing the code being executed I can only conjecture what the difference would be. Since the null reference is happening on the front end in Razor it isn't guaranteed that VS will pop up with the normal exception window. It all depends on what point in the page's life cycle that the null variable is being accessed. You should still be able to drop a break point in the controller and step through the code to find what is causing the Model being sent to the view to be null.
If you need further assistance please post the code being executed for both the controller action and the Razor page. (for info on how to post formatted code click 'Markdown Cheatsheet' link)
Great investigative question! Keep up the good work! Happy Coding!