网页上的一个链接我直接点开与复制到地址栏打开 怎么会显示的是两个不同的页面

我把两次的链接对比了的,一模一样的啊,被设置了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).

温馨提示:答案为网友推荐,仅供参考
第1个回答  2013-08-30
哈哈,直接点开,赋值地址进入是两种不同的操作,在asp.net后台中,有个叫ispostback的变量,可以用来判断是否是“提交进入页面”还是“直接通过地址进入页面”,当然,if(!ispostback)中的逻辑可以随便写,甚至引用其他界面也说不定啊。

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网