[英]WCF SOAP Web Service with Windows Authentication stops working, after adding an HTTPS binding to IIS
[英]IIS auto start application stops working with Windows Authentication
我想自動啟動 IIS 上的應用程序。 我按照這里的步驟操作,它奏效了! https://www.taithienbo.com/how-to-auto-start-and-keep-an-asp-net-core-web-application-and-keep-it-running-on-iis/
但這是在 IIS 中的身份驗證模式設置為匿名身份驗證時。 然后我想將 Windows 身份驗證添加到我的應用程序中,並且我能夠成功地做到這一點。 除了,我的網站的自動啟動不再起作用。 您可以讓您的 IIS 應用程序以 Windows 身份驗證模式自動啟動嗎? 如果是這樣,怎么做?
對於那些正在尋找答案的人 - 我遇到了同樣的問題,我的解決方案是:
在 web.config 中全局啟用匿名
<system.webServer> <security> <authentication> <windowsAuthentication enabled="true" /> <anonymousAuthentication enabled="true"/> </authentication> </security> </system.webServer>
添加一個默認 controller 與空 Route 和 AllowAnonymous 屬性
[Route("")] [ApiController] [AllowAnonymous] public class DefaultController: ControllerBase { private readonly ILogger _logger; public DefaultController(ILogger logger) { _logger = logger; } [HttpGet] public ContentResult Get() { _logger.LogTrace("Warmup called"); return Content("This is my webapi. see <a href='swagger/index.html'>here</a>", "text/html; charset=utf-8"); } }
對於那些需要身份驗證的控制器,添加一個 Authorize 屬性:
[Route("[controller]")] [ApiController] [EnableCors] [Authorize] public class MyAuthenticatedController: ControllerBase { //... }
您還可以添加單獨的 controller 用於預熱應用程序並在applicationInitialization
web.config 的部分指定其路由(適用於 Z5DA5ACF461B4EFB7E76EC861060B2126Z >= 8):
<system.webServer>
<!-- ... -->
<applicationInitialization doAppInitAfterRestart="true" skipManagedModules="false">
<add initializationPage="/warmup" />
</applicationInitialization>
</system.webServer>
最后,一個對我有幫助的答案。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.