遇到的问题非常奇怪,总的现象就是程序在发布在服务器上运行时好好的,但在我本机上调试(代码一样的)就出问题了,登陆就出现
Server Error in '/rdnpi' Application.
--------------------------------------------------------------------------------Object reference not set to an instance of an object.
代码出错在:NPI.Core.Domain.Users npiUser = Context.User as NPI.Core.Domain.Users;
npiUser.CurrentGroup = Users.GetCurrentGroup(Convert.ToInt32(User.Identity.Name));一调试原来 npiUser 是null的,我想很可能是as转换不成功吧,但为什么在服务器上又是好的呢?这个跟系统平台有关吗?跟asp.net版本或是iis有关吗?
实在是不清楚,请大侠们指点一下啊
Server Error in '/rdnpi' Application.
--------------------------------------------------------------------------------Object reference not set to an instance of an object.
代码出错在:NPI.Core.Domain.Users npiUser = Context.User as NPI.Core.Domain.Users;
npiUser.CurrentGroup = Users.GetCurrentGroup(Convert.ToInt32(User.Identity.Name));一调试原来 npiUser 是null的,我想很可能是as转换不成功吧,但为什么在服务器上又是好的呢?这个跟系统平台有关吗?跟asp.net版本或是iis有关吗?
实在是不清楚,请大侠们指点一下啊
解决方案 »
- 与.net 验证控件有关
- 【转】在ASP.NET MVC中实现基于URL的权限控制
- 看過《圣殿祭司的ASP.NET 2.0开发详解--使用C#》或者《asp.net 2.0 高級編程4》的進來看看~~~
- DataGrid中添加用户控件的问题
- %%%%%%% 动态增加控件,为什么没有触发事件呢,请高手指教 ***********
- showModelessDialog窗口中DataGrid的新增的数据当退出窗口后下次进去就看不到了
- 请转贴,共同抵制日货!
- 怎么让页面Excel文档的链接在Excelz中打开!而不是嵌在页面里显示!
- EnableViewState的问题?请指教.
- 几天没上 MSDN,发现多一个角。
- ASP.NET网站如何调用动态链接库DLL
- GridView 双击直接可编辑可更新
if (Context.User.Identity.IsAuthenticated && Context.User != null)
{}
条件下的,而User.Identity.Name是相当于Context.User.Identity里面的,所以,我调试的时候是非空的
Context.User as NPI.Core.Domain.Users 转换不了了
NPI.Core.Domain.Users和Context.User的兼容性
如果不兼容就会返回null
你强转一下 看报错不
(NPI.Core.Domain.Users)Context.User
因为它们里面的结构不一样,NPI.Croe.Domain.Uses里的属性要多些。