https网站访问iframe下的http内容
广告:
如何在https站点的iframe中允许http内容:
解决方案:新建一个代理页面HttpsPage.aspx,在服务器中访问http内容(少数有效)
前端代码:
<%string weixinpay="";
if (ViewData["weixinpay"]!=null)
weixinpay= ViewData["weixinpay"].ToString();
string ifaurl=payApi+"weixinpay.aspx?body="+weixinpay;
if (Request.Url.ToString().ToLower().Contains("ttps://"))
ifaurl=webd+"Jqueryfile/HttpsPage.aspx?url="+ifaurl+"&http="+payApi; %>
<div class="code_pic" id="showWechatUrl"><iframe src="<%=ifaurl%>" frameborder="0" scrolling="no"></iframe></div>
后端代码:
string url = "";
if (Request.QueryString["url"] != null)
url = Request.QueryString["url"].ToString();
string http = ""; //相对网址转为 http互联网网址
if (Request.QueryString["http"] != null)
http = Request.QueryString["http"].ToString();
if (url != "")
{
//Response.Write(url);
string res = HttpService.Get(url);
Regex Areareg3 = new Regex(@"src=""(.*?)""", RegexOptions.IgnoreCase | RegexOptions.Compiled);
res = Areareg3.Replace(res, "src=\""+http+"$1\"");
Regex Areareg2 = new Regex(@"href=""(.*?)""", RegexOptions.IgnoreCase | RegexOptions.Compiled);
res = Areareg2.Replace(res, "href=\"" + http + "$1\"");
Response.Write(res);
}
Response.End();
广告: