如何解决window.showmodaldialog跨域无法获得返回值的问题
答案:2 悬赏:50 手机版
解决时间 2021-02-25 07:05
- 提问者网友:愿为果
- 2021-02-24 09:13
如何解决window.showmodaldialog跨域无法获得返回值的问题
最佳答案
- 五星知识达人网友:蕴藏春秋
- 2021-02-24 10:04
跨域取值
一般的做法,要用aspx把数据采集到本地进行调用
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml;
using System.Net;
using System.IO;
using System.Text;
namespace NetCMS.Web
{
public partial class AjaxGeturl : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string url = string.Empty;
url = Request.QueryString["url"];
Response.Write(GetResStr(url, "utf-8"));
Response.End();
}
}
string GetResStr(string url, string Encod)
{
WebRequest WReq;
WebResponse WResp;
StreamReader sr;
WReq = WebRequest.Create(url);
WResp = WReq.GetResponse();
sr = new StreamReader(WResp.GetResponseStream(), Encoding.GetEncoding(Encod));
string retValue = sr.ReadToEnd();
sr.Close();
return retValue;
}
}
}
一般的做法,要用aspx把数据采集到本地进行调用
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml;
using System.Net;
using System.IO;
using System.Text;
namespace NetCMS.Web
{
public partial class AjaxGeturl : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string url = string.Empty;
url = Request.QueryString["url"];
Response.Write(GetResStr(url, "utf-8"));
Response.End();
}
}
string GetResStr(string url, string Encod)
{
WebRequest WReq;
WebResponse WResp;
StreamReader sr;
WReq = WebRequest.Create(url);
WResp = WReq.GetResponse();
sr = new StreamReader(WResp.GetResponseStream(), Encoding.GetEncoding(Encod));
string retValue = sr.ReadToEnd();
sr.Close();
return retValue;
}
}
}
全部回答
- 1楼网友:我住北渡口
- 2021-02-24 10:16
搜一下:如何解决window.showmodaldialog跨域无法获得返回值的问题
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯