创建WCF跨域交互界面
创始人
2024-06-14 09:41:25
0

接下来我们将学习WCF跨域交互各个角度出来,来讲述WCF跨域交互的功能,这主要包括C#3.0,VB9.0,WCF,WPF,WP,LINQ,AJAX,mobile开发,Cardspace,智能客户端。

下面是我扫除这一障碍的一个笨得不能再笨的方法 #t#

第一步:在项目中创建一个页面Proxy.aspx,作为ExtJs与Wcf跨域操作的代理页面。这个页面和ExtJs位于一个位置,并且去除页面中的HTML代码:

WCF跨域交互后台代码为:

  1. Proxy.aspx.cs  
  2. using System;  
  3. using System.Collections;  
  4. using System.Configuration;  
  5. using System.Data;  
  6. using System.Linq;  
  7. using System.Web;  
  8. using System.Web.Security;  
  9. using System.Web.UI;  
  10. using System.Web.UI.HtmlControls;  
  11. using System.Web.UI.WebControls;  
  12. using System.Web.UI.WebControls.WebParts;  
  13. using System.Xml.Linq;  
  14. using System.Collections.Specialized;  
  15.     
  16. namespace ExtJs_Wcf_Linq_PageGrid  
  17. {  
  18. public partial class Proxy : System.Web.UI.Page  
  19. {  
  20. protected void Page_Load(object sender, EventArgs e)  
  21. {  
  22. string remoteUrl = Request.QueryString["remote"];  
  23. using(System.Net.WebClient wc = new System.Net.WebClient())  
  24. {  
  25. NameValueCollection nvc = Request.QueryString;  
  26. foreach (string key in nvc.Keys)  
  27. {  
  28. if (key != "remote")  
  29. {  
  30. if (remoteUrl.IndexOf("?") == -1)  
  31. {  
  32. remoteUrlremoteUrl = remoteUrl + "?"+key+"="+ nvc[key];  
  33. continue;  
  34. }  
  35. remoteUrlremoteUrl = remoteUrl + "&" + key + "=" + nvc[key];  
  36. }  
  37. }  
  38. string response = wc.DownloadString(remoteUrl);  
  39. Response.Write(response);  
  40. Response.End();  
  41. }  
  42. }  
  43. }  

相关内容

热门资讯

如何允许远程连接到MySQL数... [[277004]]【51CTO.com快译】默认情况下,MySQL服务器仅侦听来自localhos...
如何利用交换机和端口设置来管理... 在网络管理中,总是有些人让管理员头疼。下面我们就将介绍一下一个网管员利用交换机以及端口设置等来进行D...
施耐德电气数据中心整体解决方案... 近日,全球能效管理专家施耐德电气正式启动大型体验活动“能效中国行——2012卡车巡展”,作为该活动的...
20个非常棒的扁平设计免费资源 Apple设备的平面图标PSD免费平板UI 平板UI套件24平图标Freen平板UI套件PSD径向平...
德国电信门户网站可实时显示全球... 德国电信周三推出一个门户网站,直观地实时提供其安装在全球各地的传感器网络检测到的网络攻击状况。该网站...
为啥国人偏爱 Mybatis,... 关于 SQL 和 ORM 的争论,永远都不会终止,我也一直在思考这个问题。昨天又跟群里的小伙伴进行...
《非诚勿扰》红人闫凤娇被曝厕所... 【51CTO.com 综合消息360安全专家提醒说,“闫凤娇”、“非诚勿扰”已经被黑客盯上成为了“木...
2012年第四季度互联网状况报... [[71653]]  北京时间4月25日消息,据国外媒体报道,全球知名的云平台公司Akamai Te...