我从一个MVC应用程序中获取了一个带身份验证的iCal订阅,下面是对这个SO问题的回答:
Serving an iCalendar file in ASPNET MVC with authentication
使用DDay.iCal库从数据库中的事件动态创建iCal流。
这个解决方案在本地开发服务器上运行良好: OSX Calendar和Outlook都可以订阅和接收应用程序的更新。
但是,在我的web主机上的共享服务器上,Calendar和Outlook的身份验证都失败了。也就是说,在(正确的)失败后,它们都会一直要求我提供用户名和密码。
编辑:如果我将浏览器指向日历URL,它也无法通过身份验证。
编辑:获取怪人-火狐验证并获取iCal文件。Safari、Chrome和IE无法通过身份验证。
如果我使用相同的凭证将curl指向日历URL,那么我就成功了(即我获得了所需的iCal文件)。当然,也可以使用相同的凭据登录到MVC应用程序。
编辑-我想我知道发生了什么,但我不知道如何修复它。在我的OnAuthorization()
中,我只添加了WWW-Authentication Basic
,但在Fiddler中,我可以看到提供了三种类型的身份验证:
HTTP/1.1 401 Unauthorized
WWW-Authenticate: Basic realm="Secure Calendar"
WWW-Authenticate: Negotiate
WWW-Authenticate: NTLM
... etc ...
在这一点上,只有Firefox使用Basic Authorization进行响应,这是成功的。
GET <<URL>> HTTP/1.1
...
Authorization: Basic <<encoded credentials>>
IE使用协商进行响应,协商失败
GET <<URL>> HTTP/1.1
...
Authorization Negotiate <<encoded stuff>>
谁在添加另外两个,我如何才能使其停止?以下是来自服务器响应的更多详细信息:
HTTP/1.1 401 Unauthorized
Cache-Control: private
Transfer-Encoding: chunked
Content-Type: text/html
Server: Microsoft-IIS/7.5
X-AspNetMvc-Version: 3.0
WWW-Authenticate: Basic realm="Secure Calendar"
X-AspNet-Version: 4.0.30319
WWW-Authenticate: Negotiate
WWW-Authenticate: NTLM
X-Powered-By: ASP.NET
X-Powered-By-Plesk: PleskWin
Date: Tue, 23 Oct 2012 13:27:48 GMT
谢谢你,埃里克
发布于 2012-10-24 11:52:15
哈哈,答案在于IIS配置。
我要求我主机上的管理员关闭其他身份验证,这破坏了除iCal提要之外的所有内容。
现在,他们又重新打开了几个,MVC站点和带有身份验证的日历提要一样工作……呼!非常非常灿烂的微笑。
下面是我们最终得到的IIS配置:
Name Status Response Type
Anonymous Authentication Enabled
ASP.NET Impersonation Disabled
Basic Authentication Disabled HTTP 401 Challenge
Digest Authentication Disabled HTTP 401 Challenge
Forms Authentication Enabled HTTP 302 Login/Redirect
Windows Authentication Enabled HTTP 401 Challenge
我不确定为什么这会成功--也不知道还有什么可能会破坏--但今天我很高兴。
发布于 2012-10-24 14:22:11
WWW-Authenticate: Negotiate
WWW-Authenticate: NTLM
由Windows身份验证使用。由于您最终启用了匿名身份验证,因此不会显示所有WWW-Authenticate
标头。
发布于 2017-02-13 20:09:24
简单的方法:
如果您希望从每个新创建的域中删除此"X-Powered-By-Plesk“头,您可以在”默认主机模板“的"httpdocs”文件夹中创建一个默认的web.config文件。
此默认网站模板通常位于:"C:\inetpub\vhosts.skel\0\httpdocs“下。默认情况下,创建新网站时将使用该web.config文件。
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<httpProtocol>
<customHeaders>
<remove name="X-Powered-By-Plesk" />
</customHeaders>
</httpProtocol>
</system.webServer>
</configuration>
提示1:您可以使用此方法删除任何不需要的自定义标头(以便不会告诉太多关于您的服务器的坏人):
<remove name="X-Powered-By"/>
<remove name="X-Powered-By-Plesk"/>
<remove name="X-AspNet-Version"/>
<remove name="X-AspNetMvc-Version"/>
提示2:如果您想删除任何动态标头(如著名的“服务器”标头),则需要使用outboundRules进行操作:
<configuration>
<system.webServer>
<rewrite>
<outboundRules>
<rule name="StripHeader_Server" patternSyntax="Wildcard">
<match serverVariable="RESPONSE_SERVER" pattern="*"/>
<action type="Rewrite" value=""></action>
</rule>
<rule name="StripHeader_ETag">
<match serverVariable="RESPONSE_ETag" pattern=".+" />
<action type="Rewrite" value="" />
</rule>
</outboundRules>
</rewrite>
</system.webServer>
</configuration>
提示3:此外,您还可以使用这个默认的web.config文件来设置您想要用于每个新网站的所有配置参数(例如:为您的网站定义默认文档列表,如本Plesk帮助文章所述:https://support.plesk.com/hc/en-us/articles/213364049-How-to-configure-global-default-document-settings-in-Parallels-Plesk )
https://stackoverflow.com/questions/13023519
复制相似问题