VS2013调试时的认证问题-iis express [英] Authentication issue when debugging in VS2013 - iis express

查看:21
本文介绍了VS2013调试时的认证问题-iis express的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在 Visual Studio 2013 中调试时获取 Windows 用户名.我只是使用:

I'm trying to pick up the windows username when debugging in Visual Studio 2013. I am simply using:

httpcontext.current.user.identity.name

如果我在我的开发服务器上运行它,它工作正常,如果我在任何以前版本的 Visual Studio 上以调试模式运行它,它也能正常工作.

If I run this on my Dev Server it works fine, if I run it in debug mode on any previous version of Visual Studio it also works fine.

我的问题是 - 如果我在 Visual Studio 2013 上运行它,我会得到一个空字符串.

My problems is - If i run this on visual studio 2013 I get an empty string.

我的网络配置如下.

<system.web>
    <authentication mode="Windows"/>
    <identity impersonate="false"/>
    <authorization>
       <allow users="*"/>
    </authorization>
    <compilation debug="true" strict="false" explicit="true" targetFramework="4.0"/>
    <customErrors mode="Off"/>
</system.web>

推荐答案

当我研究这个时,我找到了我的答案,但在互联网上找不到答案,所以我想我会分享这个:

As I was researching this I found my answer, but can't find the answer on the internet, so I thought I'd share this:

我通过修改我的 applicationhost.config 文件解决了我的问题.我的文件保存在My DocumentsIISExpressconfig"文件夹中.

I fixed my issue by modifying my applicationhost.config file. My file was saved in the "My DocumentsIISExpressconfig" folder.

似乎 VS2013 忽略了我的 web.config 文件并应用了不同的身份验证方法.

It seems that VS2013 was ignoring my web.config file and applying different authentication methods.

我不得不修改文件的这一部分,如下所示.实际上,我只是将anonymousAuthentication 修改为false,将windowsAuthentication 模式修改为true.

I had to modify this portion of the file to look like the below. In truth, I only modified the anonymousAuthentication to be false and the windowsAuthentication mode to true.

<authentication>

  <anonymousAuthentication enabled="false" userName="" />

  <basicAuthentication enabled="false" />

  <clientCertificateMappingAuthentication enabled="false" />

  <digestAuthentication enabled="false" />

  <iisClientCertificateMappingAuthentication enabled="false">
  </iisClientCertificateMappingAuthentication>

  <windowsAuthentication enabled="true">
    <providers>
      <add value="Negotiate" />
      <add value="NTLM" />
    </providers>
  </windowsAuthentication>

</authentication>

这篇关于VS2013调试时的认证问题-iis express的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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