MVC5 VS Windows身份验证在IIS 7.5:无法登录 [英] MVC5 vs Windows Authentication in IIS 7.5: unable to login

查看:765
本文介绍了MVC5 VS Windows身份验证在IIS 7.5:无法登录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想,以确保Asp.Net MVC5应用程序中使用Windows身份验证。

I'm trying to secure Asp.Net MVC5 application to use Windows authentication.

我主要跟着这篇文章: HTTP ://msdn.microsoft.com/en-us/library/gg703322%28v=vs.98%29.aspx

I have mostly followed this article: http://msdn.microsoft.com/en-us/library/gg703322%28v=vs.98%29.aspx

而当我去的网页,我与登录/用户名文本框psented $ P $:

And when I go to pages, I'm presented with login/username textboxes:

我输入正确的用户名/密码,我问了相同的细节一次。一次又一次。我一直试图做的登录前添加计算机名(本地计算机没有一个域),但没有运气。

I type correct username/password and I'm asked for the same details again. And again and again. I've tried to do add machine name before the login ( local machine does not have a domain), but no luck.

在web.config中我有:

In web.config I have:

<authentication mode="Windows" />

在IIS 7.5中我有进行身份验证以下内容:

In IIS 7.5 I have the following for the authentication:

控制器动作,我要求是这样的:

Controller action I request looks like this:

public partial class HomeController : BaseController
{
    private readonly IMediator mediator;

    public HomeController(IMediator mediator)
    {
        this.mediator = mediator;
    }

    public virtual ActionResult Index()
    {
        var model = mediator.Request(new MenuModelQuery());
        return View(model);
    }

如果我关掉任何身份验证(启用匿名) - 一切工作正常。我曾尝试与不同的用户对应用程序池的网站玩 - 没有变化。我已经加入 [使用AllowAnonymous] 属性控制器动作 - 没有变化。我曾尝试[授权(USER =trailmax)] - 在行为中没有任何变化。

If I turn off any authentication (enable anonymous) - everything works fine. I have tried playing with different user for Application Pool for the web-site - no change. I have added [AllowAnonymous] attribute to the controller action - no change. I have tried [Authorize(User="trailmax")] - no change in the behaviour.

提琴手表明,当我在把用户名/密码身份验证标头传递每次:

Fiddler shows that authenticate header is passed every time when I put username/password in:

请求:

GET http://reporting.dev/ HTTP/1.1
Host: reporting.dev
Connection: keep-alive
Cache-Control: max-age=0
Authorization: Negotiate TlRMTVNTUAABblahblahblahblah=
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8

响应:

HTTP/1.1 401 Unauthorized
Content-Type: text/html; charset=us-ascii
Server: Microsoft-HTTPAPI/2.0
WWW-Authenticate: Negotiate TlRMTVNTUAACAAA_some_long_stringkLP9zgEAAAAA
Date: Fri, 20 Dec 2013 18:44:50 GMT
Content-Length: 341
Proxy-Support: Session-Based-Authentication

我的想法。你可以建议什么吗?

I'm out of ideas. Can you suggest anything?

推荐答案

我已经找到了问题的根源 - hosts文件。
每次我做网站的发展,我创建主机文件中的记录,所以它是稍微更加人性化。

I have found the source of the problem - hosts file. Every time I do web-site development, I create a record in hosts file, so it is slightly more user friendly.

当我试图通过访问该网站的http://本地主机:81 windows身份验证正常工作,并采取了从第一次尝试密码

As soon as I have tried accessing the site via http://localhost:81 windows authentication worked fine and took in the password from the first attempt.

不知道到底为什么这次没有通过域名主机通过工作。不过,我可以猜测,IIS了混淆网站的域名和本地工作组/域名。一些安全功能。

Don't know why exactly this did not work via domain name via hosts. But I can guess that IIS got confused with site domain-name and local workgroup/domain name. Some sort of security feature.

这篇关于MVC5 VS Windows身份验证在IIS 7.5:无法登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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