我无法将asp.net .NET 4.5网站部署到在Windows 2008 R2上运行的IIS 7服务器上,该服务器在远程虚拟机中运行。 当我尝试访问我的机器中的虚拟服务器中的受限制成员页面(也称为VS2012中的debuging)时,它完美地工作,将我重定向到登录页面,以便用户登录并访问成员页面。
但是,当我在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);
}
}
}
答案 0 :(得分:0)
这里可能会发生一些事情,但是我会猜测你的问题出在这个表达式上:
HttpContext.Current.User.Identity.Name
您是否已将IIS 7配置为使用Windows身份验证?