0

我遇到了一个错误,我无法在网上找到答案。我用 IIS 角色和 ASP.NET 角色服务创建了一个新的虚拟 Server 2008 R2 Standard 框。服务器用于生产。我将一个网站复制到服务器,但它已经停止工作;具体来说,RoleManagerModule 正在引发 NullReferenceException。这发生在任何 *.aspx 页面上,但不会发生在 robots.txt 等静态页面上。即使对于没有任何授权规则的页面,也会发生此错误。以下是应用程序事件日志中错误的相关片段:

Exception information: 
    Exception type: NullReferenceException 
    Exception message: Object reference not set to an instance of an object. 

Request information: 
    Request URL: ******** 
    Request path: / 
    User host address: ******** 
    User:  
    Is authenticated: False 
    Authentication Type:  
    Thread account name: ******** 

Thread information: 
    Thread ID: 8 
    Thread account name: ******** 
    Is impersonating: False 
    Stack trace:    at System.Web.Security.RoleManagerModule.OnEnter(Object source, EventArgs eventArgs)
   at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

仅当在 web.config 中启用角色管理器时才会发生这种情况:

<roleManager defaultProvider="EWRO" enabled="true">

如果我删除或设置为 false 启用的属性,aspx 页面会正确响应。我已经尽可能地匹配网站当前运行的服务器的配置和安装服务。您可能会注意到我有一个自定义角色提供程序,但是即使我删除了 defaultProvider 属性也会发生相同的异常。AspNetSqlRoleProvider 无论如何都会失败,但它没有达到这一点。

一个解决方案或找到解决方案的步骤将不胜感激。

4

2 回答 2

0

我最终重新安装了 IIS 服务器角色,它解决了这个问题。抱歉,对于发现此问题的任何其他人,我无法提供更多帮助。

于 2012-07-26T18:05:00.097 回答
0

发生此错误是因为 RoleManager 找不到用户身份,通常是在启用匿名身份验证时。

要解决它,请尝试编辑

c:\windows\system32\inetsrv\config\applicationHost.config

并将 DefaultAuthenticationModule 放在 RoleManagerModule 之前

<add name="DefaultAuthentication" type="System.Web.Security.DefaultAuthenticationModule" preCondition="managedHandler" />
<add name="RoleManager" type="System.Web.Security.RoleManagerModule" preCondition="managedHandler" />
于 2020-03-26T11:05:59.997 回答