简体   繁体   中英

Asp.net Core 2.1 NullReferenceException Error in Production but Not Development

So this one is throwing me for a loop. I have a asp.net core 2.1 app that I have recently moved from development to production. The app works perfectly in development with no issues or errors. When I move the app to the production server I am getting a null reference exception when trying to call any page from the main menu.

来自站点的示例错误

For this page its stating that my error is on line 85. When I look at line 85 in my development code its a simple assignment operator where Form = new Form(). 代码图片

Does anyone have any ideas on how to fix this? I can't seem to understand what is going on.

Okay so thanks to @dropoutcoder for idea of remote debugging. After I was able to establish the connection and look through the code I found out the error was due to a null return from a database get that I was doing for the employee. I was in fact retrieving an id from the windowsidentity but it was not an id that I had stored in my database which is why I received the null error. I do plan on continuing to use the remote debugging in the future as without it, I probably would not have been able to understand the problem. I have also changed my code to handle the possible null exception that may happen from my code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM