【发布时间】:2016-11-10 05:52:20
【问题描述】:
我的基于 https 的站点(站点 A)使用基于 http 的站点 B 的图像。我导致混合内容错误。为了解决这个问题,我找到了将每个外部链接(如http://www.siteB.com/imageX.png)与我的控制器方法交换的解决方案,该方法可以转发到外部图像。新的链接格式为:
方法/api/misc/forward的代码如下:
[HttpGet]
public async Task<HttpResponseMessage> Forward(string url)
{
HttpResponseMessage httpResponseMessage = new HttpResponseMessage();
try
{
var response = Request.CreateResponse(HttpStatusCode.Found);
response.Headers.Location = new Uri(HttpUtility.UrlDecode(url));
return response;
}
catch (Exception ex)
{
httpResponseMessage.StatusCode = HttpStatusCode.NotFound;
_loggerService.LogException(ex, url);
}
return httpResponseMessage;
}
但浏览器仍然能够将其识别为混合模式.... 为什么? 发送到浏览器的原始图片链接来自基于 https 的站点。
有什么快速提示吗?我不想缓存站点 B 中的所有图像:)。
【问题讨论】:
标签: c# asp.net-mvc-4 mixed-content