首页 \ 问答 \ IIS 7.5 Windows +匿名身份验证间歇性地工作(IIS 7.5 Windows + Anonymous Authentication works intermittently)

IIS 7.5 Windows +匿名身份验证间歇性地工作(IIS 7.5 Windows + Anonymous Authentication works intermittently)

我有一个MVC 3站点,其中一些控制器/操作需要Windows身份验证,其他不需要,即匿名。

该网站运行良好一段时间,我可以访问匿名操作和经过身份验证的操作(没有提示,凭据会自动在Chrome / IE / FireFox中传递)但随后身份验证才停止工作,我开始收到提示输入永远不会的凭据公认。

我必须重新启动整个服务器,或者将站点物理路径更改为另一个应用程序,在返回原始站点时进行经过身份验证的请求。 然后冲洗并重复,但我找不到任何模式。 如果我什么都不做,那么身份验证就会破坏。

我有IIS 7.5配置如下:

应用程序池

  • .NET Framework版本 - v4.0
  • 管理管道模式 - 集成
  • 应用程序池标识 - ApplicationPoolIdentity

现场

  • 匿名身份验证 - 已启用
  • 匿名用户身份 - IUSR [我相信这是默认]
  • ASP.NET模拟 - 已禁用
  • 表单身份验证 - 禁用
  • Windows身份验证 - 已启用
  • Windows身份验证扩展保护 - 关闭
  • Windows身份验证启用内核模式身份验证 - 打开
  • Windows身份验证提供程序 - 协商,NTLM

控制器

// Anonymous Controller
    public class HomeController : Controller
    {
       public ActionResult Index()
       {
          return this.View();
       }
    }

// Authenticated Controller
    [Authorize]
    public class AnotherController : Controller
    {
       public ActionResult Index()
       {
          var viewModel = // create view model;
          return this.View(viewModel);
       }
    }

在任何时候,身份验证工作与否/返回/ home / index都会返回200.完全符合预期。 当身份验证正在运行时,对/ another / index的GET请求如下所示:

> GET /another/index
  Response: 401
  Response Headers: WWW-Authenticate: NTLM, WWW-Authenticate:Negotiate


> GET /another/index
  Request Header: Authorization: Negotiate TlRMIVNDUAACAAAAl4II4gAAAAAAAAAAAAAAAAAAAAAGAbEdAAAADw==
  Response: 401
  Response Header: WWW-Authenticate: Negotiate TlRMTVNTUAACAAAACAAEADgAAAAVgoni2YSlwIHmCL4AAAAAAAAAAIgAiAA8AAAABgGxHQAAAA9GAFIAAgAEAEYAUgABABQARgBSAEkATgBUAFIAQQBOAEUAVAAEABQARgBSAC5ATgBEAFMALgBjAG8AbQADACoARgBSAKkATgBUAFIAQQBUAEUAVAAuAGCAcgAuAG4AZACzAC4AYvBvAG0ABQAOAE4ARABTAC6AYwBvAG0ABwAIAOST3lPK980BAAAAAA==

 > GET /another/index
   Request Headers: Authorization: Negotiate TlRMTVNTUAACAAAACAAEADgAAAAVgoni2YSlwIHmCL4AAAAAAAAAAIgAiAA8AAAABgGxHQAAAA9GAFIAAgAEAEYAUgABABQARgBSAEkATgBUAFIAQQBOAEUAVAAEABQARgBSAC5ATgBEAFMALgBjAG8AbQADACoARgBSAKkATgBUAFIAQQBUAEUAVAAuAGCAcgAuAG4AZACzAC4AYvBvAG0ABQAOAE4ARABTAC6AYwBvAG0ABwAIAOST3lPK980BAAAAAA==
   Response: 200

当身份验证中断对/ another / index的GET请求时,如下所示:

> GET /another/index
  Response: 401
  Response Headers: WWW-Authenticate: NTLM, WWW-Authenticate:Negotiate


> GET /another/index
  Request Header: Authorization: Negotiate TlRMIVNDUAACAAAAl4II4gAAAAAAAAAAAAAAAAAAAAAGAbEdAAAADw==
  Response: 401
  Response Headers: WWW-Authenticate: NTLM, WWW-Authenticate:Negotiate

此时我被提示输入凭据,我输入相同的请求,重新响应:

> GET /another/index
      Request Header: Authorization: Negotiate TlRMIVNDUAACAAAAl4II4gAAAAAAAAAAAAAAAAAAAAAGAbEdAAAADw==
      Response: 401
      Response Headers: WWW-Authenticate: NTLM, WWW-Authenticate:Negotiate

有没有人知道我是否有错误的配置(我很确定我没有或我不希望它可以工作),为什么认证中断或我如何阻止它?

非常感谢大家。


I have an MVC 3 site in which some controllers/action require Windows authentication, other do not, i.e. are anonymous.

The site runs fine for a while, I can access both the anonymous actions and authenticated ones (without prompting, credentials are passed automatically in Chrome/IE/FireFox) but then the authentication just stops working, I start getting prompted for credentials that are never accepted.

I have to either restart the whole server, or change the site physical path to another app, make an authenticated request, which works, when back to the original site. The situation is then rinse and repeat, but I can find no pattern to it. If I do nothing, the authentication stays broken.

I have IIS 7.5 configured as follows:

App Pool

  • .NET Framework Version - v4.0
  • Managed Pipeline Mode - Integrated
  • Application Pool Identity - ApplicationPoolIdentity

Site

  • Anonymous Authentication - Enabled
  • Anonymous user identity - IUSR [I believe this is the default]
  • ASP.NET Impersonation - Disabled
  • Forms Authentication - Disabled
  • Windows Authentication - Enabled
  • Windows Authentication Extended Protection - Off
  • Windows Authentication Enable Kernel-mode authentication - On
  • Windows Authentication Providers - Negotiate, NTLM

Controllers

// Anonymous Controller
    public class HomeController : Controller
    {
       public ActionResult Index()
       {
          return this.View();
       }
    }

// Authenticated Controller
    [Authorize]
    public class AnotherController : Controller
    {
       public ActionResult Index()
       {
          var viewModel = // create view model;
          return this.View(viewModel);
       }
    }

At all times, authentication working or not a GET to /home/index returns 200. Exactly as expected. When authentication is working a GET request to /another/index looks like this:

> GET /another/index
  Response: 401
  Response Headers: WWW-Authenticate: NTLM, WWW-Authenticate:Negotiate


> GET /another/index
  Request Header: Authorization: Negotiate TlRMIVNDUAACAAAAl4II4gAAAAAAAAAAAAAAAAAAAAAGAbEdAAAADw==
  Response: 401
  Response Header: WWW-Authenticate: Negotiate TlRMTVNTUAACAAAACAAEADgAAAAVgoni2YSlwIHmCL4AAAAAAAAAAIgAiAA8AAAABgGxHQAAAA9GAFIAAgAEAEYAUgABABQARgBSAEkATgBUAFIAQQBOAEUAVAAEABQARgBSAC5ATgBEAFMALgBjAG8AbQADACoARgBSAKkATgBUAFIAQQBUAEUAVAAuAGCAcgAuAG4AZACzAC4AYvBvAG0ABQAOAE4ARABTAC6AYwBvAG0ABwAIAOST3lPK980BAAAAAA==

 > GET /another/index
   Request Headers: Authorization: Negotiate TlRMTVNTUAACAAAACAAEADgAAAAVgoni2YSlwIHmCL4AAAAAAAAAAIgAiAA8AAAABgGxHQAAAA9GAFIAAgAEAEYAUgABABQARgBSAEkATgBUAFIAQQBOAEUAVAAEABQARgBSAC5ATgBEAFMALgBjAG8AbQADACoARgBSAKkATgBUAFIAQQBUAEUAVAAuAGCAcgAuAG4AZACzAC4AYvBvAG0ABQAOAE4ARABTAC6AYwBvAG0ABwAIAOST3lPK980BAAAAAA==
   Response: 200

When authentication breaks a GET request to /another/index looks like this:

> GET /another/index
  Response: 401
  Response Headers: WWW-Authenticate: NTLM, WWW-Authenticate:Negotiate


> GET /another/index
  Request Header: Authorization: Negotiate TlRMIVNDUAACAAAAl4II4gAAAAAAAAAAAAAAAAAAAAAGAbEdAAAADw==
  Response: 401
  Response Headers: WWW-Authenticate: NTLM, WWW-Authenticate:Negotiate

At this point I am prompted for credentials, which I enter, the same request, response is resent:

> GET /another/index
      Request Header: Authorization: Negotiate TlRMIVNDUAACAAAAl4II4gAAAAAAAAAAAAAAAAAAAAAGAbEdAAAADw==
      Response: 401
      Response Headers: WWW-Authenticate: NTLM, WWW-Authenticate:Negotiate

Does anyone know if I have something misconfigured (I'm fairly sure I don't or I wouldn't expect it to work at all), why the authentication breaks or how I can stop it?

Many thanks all.


原文:https://stackoverflow.com/questions/14810162
更新时间:2024-03-30 17:03

最满意答案

您可以使用figurefigcaption元素, css countercounter-increment设置为1 figcaption :before伪元素:beforefont-variant设置为small-caps ,将font-style设置为italic ,将content设置为"Fig"并使用counter连接。

body {
  counter-reset: figcaption;
  counter-increment: 1;
}

figcaption:before {
  counter-increment: figcaption;
  font-variant: small-caps;
  font-style: italic;
  content: "Fig. " counter(figcaption) " ";
}
<figure>
  <img src="http://placehold.it/50x50">
  <figcaption>Short description</figcaption>
</figure>
 
<figure>
  <img src="http://placehold.it/50x50">
  <figcaption>Short description</figcaption>
<figure/>

在问题中使用html

body {
  counter-reset: figcaption;
  counter-increment: 1;
}
.imageBlockFloatLeftClearLeft > p:nth-child(2):before {
  counter-increment: figcaption;
  font-variant: small-caps;
  font-style: italic;
  font-size: .8em;
  line-height: 18px;
  content: "Fig. " counter(figcaption) ". ";
}
<div class="imageBlockFloatLeftClearLeft">
  <p>
    <img class="img-zoom" src="_images/pg_p_lewis_alex_17981019_ky_christian_war_1197.jpg" class="img-thumbnail" alt="lewis land warrant" width="140" height="143">
  </p>
  <p>Alexander Lewis's warrant #3663 to survey 200 acres of "second rate land" on the west fork of Pond River, dated 19 Oct 1798.</p>
</div>

<div class="imageBlockFloatLeftClearLeft">
  <p>
    <img class="img-zoom" src="_images/pg_p_lewis_alex_17981019_ky_christian_war_1197.jpg" class="img-thumbnail" alt="lewis land warrant" width="140" height="143">
  </p>
  <p>Alexander Lewis's warrant #3663 to survey 200 acres of "second rate land" on the west fork of Pond River, dated 19 Oct 1798.</p>
</div>

您还可以在"Fig. 1."后面添加newline "Fig. 1." <p>元素处的文本,使用css white-space设置为pre-line:first-line伪元素将样式应用于所选p元素的第一行。

.imageBlockFloatLeftClearLeft > p:nth-child(2) {
  white-space: pre-line;
}

.imageBlockFloatLeftClearLeft > p:nth-child(2):first-line {
  font-variant: small-caps;
  font-style: italic;
}
<div class="imageBlockFloatLeftClearLeft">
  <p>
    <img class="img-zoom" src="_images/pg_p_lewis_alex_17981019_ky_christian_war_1197.jpg" class="img-thumbnail" alt="lewis land warrant" width="140" height="143">
  </p>
  <p>Fig. 1.
    Alexander Lewis's warrant #3663 to survey 200 acres of "second rate land" on the west fork of Pond River, dated 19 Oct 1798.</p>
</div>

<div class="imageBlockFloatLeftClearLeft">
  <p>
    <img class="img-zoom" src="_images/pg_p_lewis_alex_17981019_ky_christian_war_1197.jpg" class="img-thumbnail" alt="lewis land warrant" width="140" height="143">
  </p>
  <p>Fig. 2.
    Alexander Lewis's warrant #3663 to survey 200 acres of "second rate land" on the west fork of Pond River, dated 19 Oct 1798.</p>
</div>


You can utilize figure, figcaption elements, css counter, counter-increment set to 1, :before pseudo element with font-variant set to small-caps, font-style set to italic, content set to "Fig" with counter concatenated.

body {
  counter-reset: figcaption;
  counter-increment: 1;
}

figcaption:before {
  counter-increment: figcaption;
  font-variant: small-caps;
  font-style: italic;
  content: "Fig. " counter(figcaption) " ";
}
<figure>
  <img src="http://placehold.it/50x50">
  <figcaption>Short description</figcaption>
</figure>
 
<figure>
  <img src="http://placehold.it/50x50">
  <figcaption>Short description</figcaption>
<figure/>

Using html at Question

body {
  counter-reset: figcaption;
  counter-increment: 1;
}
.imageBlockFloatLeftClearLeft > p:nth-child(2):before {
  counter-increment: figcaption;
  font-variant: small-caps;
  font-style: italic;
  font-size: .8em;
  line-height: 18px;
  content: "Fig. " counter(figcaption) ". ";
}
<div class="imageBlockFloatLeftClearLeft">
  <p>
    <img class="img-zoom" src="_images/pg_p_lewis_alex_17981019_ky_christian_war_1197.jpg" class="img-thumbnail" alt="lewis land warrant" width="140" height="143">
  </p>
  <p>Alexander Lewis's warrant #3663 to survey 200 acres of "second rate land" on the west fork of Pond River, dated 19 Oct 1798.</p>
</div>

<div class="imageBlockFloatLeftClearLeft">
  <p>
    <img class="img-zoom" src="_images/pg_p_lewis_alex_17981019_ky_christian_war_1197.jpg" class="img-thumbnail" alt="lewis land warrant" width="140" height="143">
  </p>
  <p>Alexander Lewis's warrant #3663 to survey 200 acres of "second rate land" on the west fork of Pond River, dated 19 Oct 1798.</p>
</div>

You can also include an a newline following "Fig. 1." text at <p> element, use css white-space set to pre-line, :first-line pseudo element to apply styles to the first line of the selected p element.

.imageBlockFloatLeftClearLeft > p:nth-child(2) {
  white-space: pre-line;
}

.imageBlockFloatLeftClearLeft > p:nth-child(2):first-line {
  font-variant: small-caps;
  font-style: italic;
}
<div class="imageBlockFloatLeftClearLeft">
  <p>
    <img class="img-zoom" src="_images/pg_p_lewis_alex_17981019_ky_christian_war_1197.jpg" class="img-thumbnail" alt="lewis land warrant" width="140" height="143">
  </p>
  <p>Fig. 1.
    Alexander Lewis's warrant #3663 to survey 200 acres of "second rate land" on the west fork of Pond River, dated 19 Oct 1798.</p>
</div>

<div class="imageBlockFloatLeftClearLeft">
  <p>
    <img class="img-zoom" src="_images/pg_p_lewis_alex_17981019_ky_christian_war_1197.jpg" class="img-thumbnail" alt="lewis land warrant" width="140" height="143">
  </p>
  <p>Fig. 2.
    Alexander Lewis's warrant #3663 to survey 200 acres of "second rate land" on the west fork of Pond River, dated 19 Oct 1798.</p>
</div>

相关问答

更多
  • 获取元素的内容(在我的示例中为普通div),并使用正则表达式搜索带字符的单词。 var div = document.querySelector("div"); var html = div.innerHTML; html = html.replace(/(\b[A-Z]{2,}\b)/g,"$1"); div.innerHTML = html; 关键点是字符类[AZ] ,它只接受字边界中包含的大写字母\b 。 文件replace 。 例 Get the Content ...
  • 您可以使用内联元素(如在同一行上设置多种字体大小。 所以在你的例子中...