我把两次的链接对比了的,一模一样的啊,被设置了referer还是什么啊.我做了个程序抓取链接地址,遇到了这种状况伤不起啊,求C#/.NET大神啊.这个问题该怎么解决啊
址,
一个可能的实现是:HttpContext.Request.UrlReferrer如果为null的话,则可能是你直接复制URL打开的,如果不为null的话,则可能是从其它页面链接过来的.
根据此,可以返回不同的内容给你,你看到也就是两个不同的页面的.有些防盗链也是基于此实现.追问
这个在程序中怎么去避免呢.
追答从其它人的博客上COPY了一点:
The situations where this ServerVariable works include the following methods of a browser loading a URL:
clicking on a straight HTML link;
submitting a form, using POST or GET, from a submit button, or client-side script (form.submit())
The situations where it doesn't work:
clicking on a Favorite, History, or the recently-typed URLs list;
clicking on 'Home' in IE's toolbar, or an item in IE's 'Links' toolbar;
using location.href or location.replace() in client-side JScript/JavaScript/VBScript;
using HierMenus (details);
typing the URL directly in the browser and hitting Enter or clicking 'Go';
launching a clickable URL from an e-mail or MS Office document;
using Response.Redirect / Server.Transfer;
using Response.AddHeader (302) or to redirect;
loading the URL with XML (see Article #2173);
misspelling the variable name (many people assume HTTP_REFERRER).
从另人的博客Copy了一段.
The situations where this ServerVariable works include the following methods of a browser loading a URL:
clicking on a straight HTML link;
submitting a form, using POST or GET, from a submit button, or client-side script (form.submit())
The situations where it doesn't work://不工作的情况
clicking on a Favorite, History, or the recently-typed URLs list;//从收藏夹,历史记录或是URL列表
clicking on 'Home' in IE's toolbar, or an item in IE's 'Links' toolbar;//IE工具栏
using location.href or location.replace() in client-side JScript/JavaScript/VBScript;//是JS的location.href
using HierMenus (details);
typing the URL directly in the browser and hitting Enter or clicking 'Go';
launching a clickable URL from an e-mail or MS Office document;
using Response.Redirect / Server.Transfer;//....
using Response.AddHeader (302) or to redirect;
loading the URL with XML (see Article #2173);
misspelling the variable name (many people assume HTTP_REFERRER).