asp.net - 资源不会自动从 Https 加载 - SecuritySwitch

标签 asp.net ssl https securityswitch

我正在从旧的 SecureWebPages 进行升级,它通过 web.config 自动在 Http 和 Https 内容之间切换。

出于某种奇怪的原因,内容如下:

<link type="text/css" href="assets/css/style.css" rel="stylesheet" />

不再自动从适当的 https 位置加载。 Google Chrome 中的控制台向我显示了以下内容:

The page at https://website.com/UserAccess.aspx ran insecure content from http://website.com/assets/css/style.css.

当我使用较旧的 SecureWebPages 时,此行为不存在。在过去,上面的 CSS 语句工作正常,没有任何错误。

我的 web.config:

<securitySwitch mode="RemoteOnly">
<paths>
  <add path="~/Register.aspx"/>
  <add path="~/SSL.Master"/>
</paths>

我的配置有问题吗?请指教。谢谢!

最佳答案

您需要告诉 SecuritySwitch 忽略您的 CSS 文件夹,甚至忽略整个 Assets 文件夹(如果它还包含图像等)。您可以将以下路径添加到 Assets 文件夹的 securitySwitch 部分。

<securitySwitch mode="RemoteOnly">
<paths>
  <add path="~/Register.aspx"/>
  <add path="~/assets/" security="Ignore"/>
</paths>
</securitySwitch>

这将告诉 SecuritySwitch 忽略 Assets 文件夹及其下的所有内容。此外,主文件的路径不会执行任何操作,因为 .master 文件永远不会提供给浏览器。

希望这会有所帮助!

关于asp.net - 资源不会自动从 Https 加载 - SecuritySwitch,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9109410/

相关文章:

asp.net - CSS 在屏幕上分布元素

asp.net - 我应该将 javascript 放在 ContentPlaceHolder 中的什么位置?

http - ruSTLs HTTP 请求响应 301

c# - 将 Div 数据属性作为数据源分配给 JQuery AutoComplete

php - Paypal 返回网址

php - 为什么 AWS Cloud9 IDE 在访问 8080 端口上的内置 PHP 服务器时会出现 "Unsupported SSL"错误?

apache - 在 AWS EC2 中安装 SSL

amazon-web-services - 验证 Google Domains 中的 AWS 证书

c# - 自托管 WCF 和 SSL(再次)

asp.net - 当我尝试保存 PNG 时,为什么会在 GDI+ 中遇到这种通用的、非描述性的错误?