null user.identity in iis 7.5

我只是一个虾纸丫 提交于 2019-12-24 03:47:11

问题


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

if (!User.Identity.IsAuthenticated)

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" />

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.

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


回答1:


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.



来源:https://stackoverflow.com/questions/12357948/null-user-identity-in-iis-7-5

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!