Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialRadu - Adrian Buha
Courses Plus Student 5,535 PointsSystem.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
1 Answer
Allan Clark
10,810 PointsWithout 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!