在C#中获取上一页网址 [英] Getting previous page URL in C#
问题描述
我们有内联网(比如abc.com),以及内部网上的一个按钮来访问一个网站(比如xyz.com)。我必须提供访问xyz.com的权限,只要他们来自内部网。
内部网在html中,因为网站在C#中。
我在内联网页面(网站链接所在的位置)编写了以下代码:
Hi,
We have intranet(say abc.com), and a button on intranet to access a website(say xyz.com). I have to provide access to xyz.com, only if they com from intranet.
Intranet is in html where as the website is in C#.
I have written the following code in the intranet page (where the website link is present)
<form action="" method="post" name="form1" target="_blank">
<input name="culture" type="hidden" value="1">
<input name="auth" type="hidden" value="culture">
<input type="button" class="button" value="test page from link" onClick="location.href='http://xyz.com/'">
</form>
我在C#页面中使用了 Request.UrlReferrer.ToString();
来授权他们来自的上一页。但它返回 NULL
。
有没有其他方法可以查看上一页的网址?
在此先感谢,
Suma。
I have used Request.UrlReferrer.ToString();
in C# page to authorize the previous page they have come from. But its returning NULL
.
Is there any other way to check the previous page url?
Thanks in advance,
Suma.
推荐答案
string urlName = Request.UrlReferrer.ToString();
它没有的情况'工作:
使用Response.Redirect / Server.Transfer;
点击收藏夹,历史记录或最近-typed URL列表;
单击IE工具栏中的Home或IE的链接工具栏中的项目;
使用location.href或location.replace()在客户端JScript / JavaScript / VBScript;
使用HierMenus(详情);
直接在浏览器中输入URL并点击Enter或点击'Go';
从电子邮件或MS Office文档启动可点击的URL;
使用Response.AddHeader或< meta http-equiv = refresh>重定向;
用XML加载URL
在referer中,你可以获得上一页的名称。
希望这可以帮到你。
The situations where it doesn't work:
using Response.Redirect / Server.Transfer;
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.AddHeader or <meta http-equiv=refresh> to redirect;
loading the URL with XML
in referer veriable u will get the previous page name.
Hope this can help you.
你好吗
以下网址上的
给出了其他方法
http://www.dotnetcurry.com/ShowArticle.aspx?ID=89 [ ^ ]
这些方法可能会有所帮助............
祝你好运
hello there
on the following URL other ways to do that are given
http://www.dotnetcurry.com/ShowArticle.aspx?ID=89[^]
these methods may be helpful ............
Best regards
没有办法获取上一页的网址。但是,我认为您可以通过两种方式解决此问题
1.IP白名单(白名单在xyz.com中列出您的内部网(abc.com)的IP地址)
2.向网站发送查询字符串说location.href ='http://xyz.com?request_from = abc并验证您的请求。
There is no way to get the previous page Url. However, I think you can resolve this issue in two ways
1.IP white listing (White list the IP address of your intranet(abc.com) in xyz.com )
2.Pass a query string to the web site say "location.href='http://xyz.com?request_from=abc and validate your request.
这篇关于在C#中获取上一页网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!