Visual Studio Debugger
The exception is System.NullReferenceException occured. The additional information is object reference not set to an instance of object.
Visual studio will highlight the line of code where error occured.
We could use "Autos" window to display the variable that being used in this program.
It can be seen that our "Model" property is "null". So, how we could access the DisplayText function if our Model is null? That is the problem.
- Press "Continue" button to continue the website running.
- Back to Controller class. There is a feature of VS called Breakpoints. It breaks the process of building our project.
- Set the breakpoints in if statement.
- Refresh the page in browser.
- In "Autos" window, we could see that our "id" variable has a value.
- Notice there are buttons to help us in analyzing each line of code. There are step into, step over, and step out.
- Try to use step over button.
- Notice that comicBook variable is null and that causes an error.
- Press step Into button to check the function.
- Take a look at if conditional statement and use the debugger. It shows that our "id" is 1 but our "comicbook.id" is 0.
- Try to solve it.