我无法将 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);
}
}
}