本文介绍了空user.identity在IIS 7.5的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在IIS 7.5中,我们都可以从下面的行一个空引用异常

We are getting a null reference exception from the following line in iis 7.5

如果(!User.Identity.IsAuthenticated)

if (!User.Identity.IsAuthenticated)

我们正在使用窗体身份验证,并启用匿名身份验证。这在IIS 7以下就好了,是我们的配置在web.config中

we are using forms authentication and also have anonymous authentication enabled. This works just fine in iis 7. Following is our configuration in web.config

<authentication mode="Forms">
        <forms name=".ASPXAUTH" loginUrl="/Auth/Login" defaultUrl="/" timeout="600" path="/" />
    </authentication>
    <authorization>
        <deny users="?" />
        <allow users="*" />
    </authorization>
    <identity impersonate="true" />

这个形式的认证选项也不会下此网站的IIS站点身份验证配置出现。我看到有唯一的选项是匿名身份验证和ASP.NET模拟。

This form authentication option also doesn't show up under iis site authentication configuration for this site. The only options I see there are Anonymous Authentication and ASP.NET Impersonation.

所以,也许它不是从阅读的Web.config出于某种原因?任何帮助是极大的appriciated。

So, maybe it is not reading from Web.config for some reason? Any help is greatly appriciated.

推荐答案

这是固定的。我看到,该网站并没有到FormsAuthentication和Anonymousidentificationmodule引用。我跑为aspnet_regiis -i为asp.net 4.0,现在该网站正常工作。

This is fixed. I saw that the site didn't have references to FormsAuthentication and Anonymousidentificationmodule. I ran aspnet_regiis -i for asp.net 4.0 and now the site works fine.

这篇关于空user.identity在IIS 7.5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 22:22