使用Windows身份验证的ASP.Net WebForms [英] ASP.Net WebForms using Windows Authentication

查看:74
本文介绍了使用Windows身份验证的ASP.Net WebForms的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用Windows身份验证,但似乎遇到了第一个障碍.

I'd like to play about with WindowsAuthentication but am seemingly falling down at the first hurdle.

因此,我创建了一个空的ASP.Net Webforms应用程序,并对web.config进行了如下修改:

So I created an empty ASP.Net Webforms app and amended the web.config as so:

<configuration>
    <system.web>
        <compilation debug="true" targetFramework="4.0"/>
        <httpRuntime/>

        <authentication mode="Windows" />
        <identity impersonate="true"/>
    </system.web>
</configuration>

启动应用程序并在页面加载时检查以下内容以获取值:

Fire up the app and on page load check the following for a value:

HttpContext.Current.User.Identity.Name

但它返回一个空字符串(并且还显示 HttpContext.Current.User.Identity.IsAuthenticated 为false).

but it returns an empty string (and also shows that HttpContext.Current.User.Identity.IsAuthenticated is false).

我的期望是看到我的Windows帐户名返回,例如 mydomain \ rob

My expectation was to see my windows account name returned e.g. mydomain\rob

我要去哪里错了?

推荐答案

在IIS中,启用匿名身份验证后Windows身份验证将不起作用.

In IIS, Windows Authentication won't work while Anonymous Authentication is enabled.

这篇关于使用Windows身份验证的ASP.Net WebForms的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆