相关疑难解决方法(0)

在VS2013中调试时的身份验证问题 - iis express

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

httpcontext.current.user.identity.name
Run Code Online (Sandbox Code Playgroud)

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

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

我的网络配置如下.

<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>
Run Code Online (Sandbox Code Playgroud)

web-config windows-authentication iis-express visual-studio-2013

102
推荐指数
7
解决办法
10万
查看次数

调试ASP.NET MVC时,IIS Express会出现"拒绝访问"错误

我创建了一个ASP.NET MVC 3项目,并在开发时使用IIS Express作为Web服务器.当我尝试调试时,我收到以下错误消息.

怎么解决这个问题?

'/'应用程序中的服务器错误.

访问被拒绝.描述:访问提供此请求所需的资源时发生错误.可能未配置服务器以访问请求的URL.

错误消息401.2.:未授权:由于服务器配置登录失败.验证您是否有权根据您提供的凭据和Web服务器上启用的身份验证方法查看此目录或页面.请与Web服务器的管理员联系以获取其他帮助.

iis debugging asp.net-mvc access-denied iis-express

100
推荐指数
8
解决办法
12万
查看次数

ASP.NET MVC 4的Windows身份验证 - 它是如何工作的,如何测试它

我之前从未使用Windows身份验证用于ASP.NET MVC Web应用程序,但是表单身份验证.最近,我有一个ASP.NET MVC 4 Web应用程序,需要为被授权登录我公司Web服务器的用户实施Windows身份验证.所以,我对Windows身份验证有一些疑问.我正在使用Visual Studio 2012.

  • Windows身份验证如何工作?

  • 如何在web.config文件中正确实现Windows身份验证?

  • 如何测试Windows身份验证是否真的适用于我的ASP.NET MVC 4网站?换句话说,我如何在本地开发PC上使用本地IIS(版本8)和我公司的真实Web服务器上使用IIS版本7进行测试?

asp.net iis-7 iis-7.5 asp.net-mvc-4 iis-8

39
推荐指数
3
解决办法
7万
查看次数

IIS Express会自动禁用我的项目的匿名身份验证,为什么?

当我将ASP.NET MVC项目从Cassini Web服务器切换到IIS Express时,会将其添加到我的applicationhost.config文件中:

<location path="MyProject">
    <system.webServer>
        <security>
            <authentication>
                <anonymousAuthentication enabled="false" />
                <windowsAuthentication enabled="false" />
            </authentication>
        </security>
    </system.webServer>
</location>
Run Code Online (Sandbox Code Playgroud)

它导致网站无法加载401.2 - 未经授权而我无法在Web.config级别修复它 - 然后它会抱怨该部分被锁定在父级别(HTTP 500.19).

我可以通过修改applicationhost.config文件来修复它,但我不明白为什么我不需要为vanilla ASP.NET MVC项目添加这样的部分.有什么不对?

我正在使用VS 11 beta,但也在2010 SP1中证实了这种奇怪的行为.IIS Express表示它的版本为7.5.

asp.net-mvc web-config visual-studio iis-express

35
推荐指数
2
解决办法
3万
查看次数

IIS Express HTTP错误401.2 - 未经授权

我已尝试过这篇文章中的建议,但我无法在Vision Studio 2010中使用IIS身份验证进行Windows身份验证.现在我收到以下错误: 401.2错误

这是我的applicationhost.config文件条目:

...
<add name="WindowsAuthenticationModule" lockItem="false" />
...
<authentication>

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

    <basicAuthentication enabled="false" />

    <clientCertificateMappingAuthentication enabled="false" />

    <digestAuthentication enabled="false" />

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

    <windowsAuthentication enabled="true" />
</authentication>
...
<sectionGroup name="authentication">
    <section name="anonymousAuthentication" overrideModeDefault="Allow" />
    <section name="basicAuthentication" overrideModeDefault="Allow" />
    <section name="clientCertificateMappingAuthentication" overrideModeDefault="Allow" />
    <section name="digestAuthentication" overrideModeDefault="Allow" />
    <section name="iisClientCertificateMappingAuthentication" overrideModeDefault="Allow" />
    <section name="windowsAuthentication" overrideModeDefault="Allow" />
</sectionGroup>
Run Code Online (Sandbox Code Playgroud)

我的web.config:

<system.web>
    <authentication mode="Windows" /> 
</system.web>
<system.webServer>
    <security>
        <authentication>
            <anonymousAuthentication enabled="false" />
            <windowsAuthentication enabled="true" />        
        </authentication>
    </security>
</system.webServer>
Run Code Online (Sandbox Code Playgroud)

这是.NET …

.net-4.0 windows-authentication iis-express

21
推荐指数
2
解决办法
3万
查看次数

Windows身份验证在IIS Express中无效,使用Visual Studio 2013,Windows 8进行调试

我刚刚将我的应用程序从Visual Studio 2012升级到Visual Studio 2013.我的Windows身份验证不再起作用了.它给了我以下错误.

     HTTP Error 401.2 - Unauthorized
     You are not authorized to view this page due to invalid authentication headers.
Run Code Online (Sandbox Code Playgroud)

在visual studio中,可以选择从网站属性本身进行身份验证.所以我禁用了匿名访问并启用了Windows身份验证,但是它要求我输入用户名和密码,如下面的弹出窗口所示.即使我在这里提供域凭据.它仍然一次又一次地给我这个弹出窗口.

在此输入图像描述 在此输入图像描述

Web配置:

     <authentication mode="Windows" />
     <authorization>
     <deny users="?" />
     </authorization>
     <identity impersonate="false" />
     <trace enabled="true" />
Run Code Online (Sandbox Code Playgroud)

IIS Express aspnetConfig:

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

        <authorization>
            <add accessType="Allow" users="*" />
        </authorization>



        <location path="Path"> …
Run Code Online (Sandbox Code Playgroud)

windows-authentication iis-express visual-studio-2013

16
推荐指数
3
解决办法
4万
查看次数

在ASP.NET中使用Windows身份验证

我正在尝试在我的ASP.NET应用程序中使用Windows身份验证.每当我尝试查看应用程序时,它都会将我发送到登录页面.如何在不通过浏览器手动登录的情况下使其工作?

web.config中

  <system.web>
    <authentication mode="Windows"></authentication>
    <anonymousIdentification enabled="false"/>
    <authorization>
      <deny users="?" />
      <allow users="*" />
    </authorization>
    <customErrors mode="Off"></customErrors>
    <identity impersonate="true"></identity>
    <compilation debug="true" targetFramework="4.0" />
    <httpRuntime />
  </system.web>
Run Code Online (Sandbox Code Playgroud)

更新IIS Express后出错

Most likely causes:
No authentication protocol (including anonymous) is selected in IIS.
Only integrated authentication is enabled, and a client browser was used that does not support integrated authentication.
Integrated authentication is enabled and the request was sent through a proxy that changed the authentication headers before they reach the Web server. …
Run Code Online (Sandbox Code Playgroud)

c# asp.net iis windows-authentication iis-express

15
推荐指数
4
解决办法
3万
查看次数

每次在VS2012中打开解决方案时,IIS express applicationhost.config安全性都会重置

我在VS2012中开发了一个使用表单身份验证的MVC4应用程序.

[authentication mode="Forms"]
  [forms loginUrl="~/Account/Login" timeout="2880" /]
[/authentication]

它使用默认的IIS 8.0 Express.

每次我从VS中打开并运行应用程序时,我收到消息:

HTTP错误401.2 - 未经授权

由于身份验证标头无效,您无权查看此页面.

我发现要避免这个屏幕,我必须将[User Documents]\IISExpress\config文件夹中applicationhost.config文件的Security部分的anonymousAuthentication和windowsAuthentication键更改为'true',以便:

[system.webServer]
  [security]
    [authentication]
      [anonymousAuthentication enabled="true" /]
      [windowsAuthentication enabled="true" /]
    [/authentication]
  [/security]
[/system.webServer]

但每次我在VS中重新打开解决方案时,密钥都会重置为false.

如何永久设置为true?

我试图将这些密钥放在应用程序的web.config中,但后来我收到了消息:

HTTP错误500.19 - 内部服务器错误

无法访问请求的页面,因为页面的相关配置数据无效.

有帮助的人吗?

security windows-authentication visual-studio-2012

10
推荐指数
1
解决办法
1万
查看次数

允许任何用户使用cors(服务器运行Windows身份验证)访问没有凭据的"信号器/集线器"

我有两台服务器

  1. SignalR主机(Windows身份验证,IIS)
  2. 其余的网页主机(表单身份验证,IIS)

我已经把它全部设置好了,它适用于Chrome中的longpolling.(1)使用Firefox并导航到时要求输入用户名和密码https://localhost:44301/signalr/hubs.

(1)使用Windows身份验证.我试图通过执行以下操作来避免身份验证web.config:

<location path="signalr">
  <system.web>
     <authorization>
        <allow users="*" />
     </authorization>
  </system.web>
</location>
Run Code Online (Sandbox Code Playgroud)

但SignalR不是路径,因为它是自动生成的.我也尝试这样做以暴露集线器,但无济于事:

<location path="~/Hubs">
  <system.web>
     <authorization>
        <allow users="*" />
     </authorization>
  </system.web>
</location>
Run Code Online (Sandbox Code Playgroud)

任何人都可以帮我找到一种方法从https:// localhost:12321/signalr /*删除身份验证?(这包括所有信号器/协商调用++)

c# web-config cors signalr

7
推荐指数
1
解决办法
1389
查看次数

Windows身份验证允许用户不工作

我正在尝试对我的应用程序使用Windows身份验证,对于我尝试过的测试只允许我自己并拒绝所有其余的

<authentication mode="Windows" />
<authorization>
    <allow users="DomainName\nogariyap" />
    <deny users="*"/>
</authorization>
Run Code Online (Sandbox Code Playgroud)

Access Denied即使我使用相同的用户登录到我的机器,它也会给我" "错误"DomainName\nogariyap"

当我把它改成这个

<allow users="*" />
Run Code Online (Sandbox Code Playgroud)

有用

我不知道为什么它不适用于特定的Windows用户?

编辑

当我添加它时它扼杀了 system.webServer

   <security>
        <authentication>
            <windowsAuthentication enabled="true" />
            <anonymousAuthentication enabled="false" />
        </authentication>
        <authorization>
          <remove users="*" roles="" verbs="" />
          <add users="DomainName\nogariyap" accessType="Allow"/>
          <add users="?" accessType="Deny"/>
        </authorization>
    </security>
Run Code Online (Sandbox Code Playgroud)

但我不知道它为什么不使用这些设置system.web,这两个设置有什么区别?

windows-authentication asp.net-mvc-4

5
推荐指数
1
解决办法
2312
查看次数