开发者

HttpContext.Current.Session is throwing exception(Object reference not set to an instance of an object.) in business class

开发者 https://www.devze.com 2023-01-15 00:48 出处:网络
In our application we have to access session objects in business class. We are using HttpContext.Current.Session to get the session value. In some cases it returns the value but mostly its throwing a

In our application we have to access session objects in business class. We are using HttpContext.Current.Session to get the session value. In some cases it returns the value but mostly its throwing a null reference exception(Object reference not set to an instance of an object). We have the following code Try

If HttpContext.Current.Session("Username") IsNot Nothing then ' Statements to be executed End If Catch ex As Exception 'Log to db End Try

Here HttpContext.Current.Session("Username") is mostly throwing an exception "Object reference not set to an instance of an object" While deb开发者_如何学运维ugging we found that HttpContext.Current itself is nothing.

Thanks. Any help on this will be appreciated.


If the production machine is IIS, there is an installation of "WebSocket protocol".

If the production machine is nginx, you need to set "proxy_set_header Connection" Upgrade ";".

0

精彩评论

暂无评论...
验证码 换一张
取 消