【发布时间】:2013-01-12 23:01:47
【问题描述】:
我在将 asp.net .NET 4.5 网站部署到在远程虚拟机中运行的 Windows 2008 R2 上运行的 IIS 7 服务器时遇到问题。 当我尝试访问我机器中虚拟服务器中的受限成员页面时(也就是在 VS2012 中调试),它运行良好,将我重定向到登录页面,以便用户登录并访问成员页面。
但是,当我在 IIS7 中托管的网站中执行完全相同的操作时,我收到以下错误:
Server Error in '/WebApp' Application.
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an object.]
WebApp.Members.RedeSocial.Page_Load(Object sender, EventArgs e) +88
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +51
System.Web.UI.Control.OnLoad(EventArgs e) +92
System.Web.UI.Control.LoadRecursive() +54
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +772
我已经对此进行了彻底的研究,但找不到解决方案。 有任何想法吗? 谢谢
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
namespace WebApp.Members
{
public partial class RedeSocial : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Service.Service1Client serv = new Service.Service1Client();
Library.Utilizador u = Library.Utilizador.loadByUsername(HttpContext.Current.User.Identity.Name);
dimRede.Text = serv.GetTamanhoRede(u.CODUTILIZADOR);
}
}
}
【问题讨论】:
-
您是否有机会展示
RedeSocial.aspxWebForm 的Page_Load方法的第88 行的内容?看起来异常的来源。 -
没有88行,只有20行。此错误发生在用户在未登录时尝试访问的所有成员页面中。上面的堆栈只是示例之一。尽管有人因为缺乏研究努力而将我的问题记下来,但我已经遇到这个问题好几天了,并且尽可能多地研究......
-
好的,然后显示您的 Page_Load 方法。没有第 88 行并不重要。如果您需要任何帮助,只需显示一些代码即可。
-
几乎所有的 NullReferenceException 情况都是一样的。请参阅“What is a NullReferenceException in .NET?”获取一些提示。
-
@NunoNeto 您找到导致此错误的解决方案了吗?
标签: asp.net iis windows-server-2008-r2