惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V
Vulnerabilities – Threatpost
V
V2EX
GbyAI
GbyAI
Recent Announcements
Recent Announcements
Microsoft Security Blog
Microsoft Security Blog
阮一峰的网络日志
阮一峰的网络日志
Hugging Face - Blog
Hugging Face - Blog
T
Tailwind CSS Blog
Y
Y Combinator Blog
C
Check Point Blog
爱范儿
爱范儿
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
美团技术团队
雷峰网
雷峰网
IT之家
IT之家
WordPress大学
WordPress大学
V
Visual Studio Blog
Microsoft Azure Blog
Microsoft Azure Blog
MyScale Blog
MyScale Blog
N
News and Events Feed by Topic
罗磊的独立博客
S
SegmentFault 最新的问题
S
Security Affairs
aimingoo的专栏
aimingoo的专栏
F
Fortinet All Blogs
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
H
Hacker News: Front Page
Google DeepMind News
Google DeepMind News
B
Blog
O
OpenAI News
C
Cisco Blogs
Simon Willison's Weblog
Simon Willison's Weblog
The Last Watchdog
The Last Watchdog
Hacker News: Ask HN
Hacker News: Ask HN
博客园_首页
人人都是产品经理
人人都是产品经理
C
Cybersecurity and Infrastructure Security Agency CISA
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Help Net Security
Help Net Security
月光博客
月光博客
J
Java Code Geeks
L
LangChain Blog
博客园 - 司徒正美
Stack Overflow Blog
Stack Overflow Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
Apple Machine Learning Research
Apple Machine Learning Research
T
The Exploit Database - CXSecurity.com
N
News and Events Feed by Topic
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

博客园 - cncxz(虫虫)

在.NET环境下为网站增加IP过滤功能 推荐几个基于.net的cms系统 超赞的10个Windows Live Writer插件 发布ASP.NET应用程序时的10个好习惯(转) 一个基于web的pdf浏览器 jQuery UI 1.0 已于2007-9-16日正式发布 Visual Studio插件大搜索(60+) 推荐一批基于web的开源html文本编辑器(40+) 终结IE6下背景图片闪烁问题 一个web应用程序统计在线用户列表的东东(带c#源码) 中了网络流氓www.e-jok.cn的招 使用 javascript 标记高亮关键词 Div+Css酷站一箩筐 在win2k3上使用卡巴斯基6.0 发布控件Express.NET.WindowsForms运行时的本地化补丁 创建为ClickOnce清单签名的.pfx格式数字证书 Windows Live Messenger去广告补丁 一个阴历阳历互相转化的类(c#源码) 小发现:sql2005中的异常处理消息框可以直接使用
ajax跨域访问代理文件下载(asp、php、asp.net)
cncxz(虫虫) · 2008-01-23 · via 博客园 - cncxz(虫虫)

最近做东西遇到了ajax跨域(cross domain)访问的问题,最后采用了Application Proxies 方式解决,即在本域内放置一个代理文件(视本域支持的开发语言选定asp、asp.net或是其他),此代理文件将url参数(QueryString)发送到目标域对应页面获取html代码,然后输出。ajax直接访问这个代理文件以达到跨域的目的。
基于asp.net的跨域访问代理文件c#代码如下:

<%@ Page Language="C#" AutoEventWireup="true"  ResponseEncoding="utf-8" %>
<%@ Import Namespace=System.Net %>
<%@ Import Namespace=System.IO %>

<script runat="server">
    
protected override void OnLoad(EventArgs e)
    
{
        
base.OnLoad(e);

        
string sourceUrl = "http://devspy.net";
        
this.Page.Response.Write(TransferHtmlPage(string.Concat(sourceUrl, "?"this.Page.Request.QueryString)));
    }

    
    
public string TransferHtmlPage(string url)
    
{
        
string result = string.Empty;
        
try
        
{            
            HttpWebRequest request 
= (HttpWebRequest)WebRequest.Create(url);
            HttpWebResponse response 
= (HttpWebResponse)request.GetResponse();
            StreamReader reader 
= new StreamReader(response.GetResponseStream(), Encoding.UTF8);
            result 
= reader.ReadToEnd();
        }

        
catch(Exception ex)
        
{
            
return string.Format(@"<p style='color:red;text-align:center;'>服务器获取文件内容出错:{0}</p>", ex.Message);
        }


        
if (!CheckVersionWaterMark(result))
            
return @"<p style='color:red;text-align:center;'>版本水印失效,请联系相关技术人员。</p>";
        
        
return result;
    }

    
    
public bool CheckVersionWaterMark(string inputString)
    
{
        
return true;//不验证水印了
        
//string pattern = "WaterMark";
        
//return Regex.IsMatch(inputString, pattern, RegexOptions.IgnoreCase);
    }


</script>


另外还有基于asp和php的实现,不再列出,感兴趣的可以下载包含这三个文件的压缩包:
https://files.cnblogs.com/cncxz/ajaxProxy.rar