查找引用URL和解析 [英] Find the referring URL and parse it
问题描述
好吧我的问题是,有两个网站的两个不同的服务器。我想要做的就是写一些按钮,为网站1,但我的服务器(网站2)。
Okay my problem is there are two websites with two different servers. What I'm trying to do is write some of the buttons for website 1, but on a page on my server (website 2).
因此,要做到这一点的方法是
So to do this the approach is
- 用户点击按钮的网站1。
- 用户被重定向到网站2。
- 我需要知道他们的,所以我知道他们正在寻找什么产品附带的网页。这将通过获取引荐URL来完成。
- 然后我需要解析URL的的productID的号码。
例如网址:website1.com/ProductDetails/?referrerPage=1&productID = #######&安培;标签=瓷砖
example URL: website1.com/ProductDetails/?referrerPage=1&productID=#######&tab=Tile
我知道我需要使用这块code到引用网址存储在一个字符串:
I know that I need to use this piece of code to store the referrer URL in a string:
myReferrer = Request.UrlReferrer.ToString();
我真的不知道在哪里把它寿。我猜我.cs文件在我的按钮?
I don't really know where to place it tho. I'm guessing in my .cs file where my button is?
protected void btnEstimate_Click(object sender, EventArgs e)
{
connection strings
{
does stuff
{
does stuff
}
所以我的问题是如何获取引用URL,然后解析出该项目ID?
So my question is how do I get the referring URL, and then parse out the item ID?
感谢您提前帮助。如果有不清楚的地方请咨询......这是我第一次问一个问题,所以我可能不清楚。谢谢!
Thanks for the help in advance. If anything is unclear please ask... this is my first time asking a question so I may be unclear. Thanks!
推荐答案
这应该给你你想要什么:
This should give you what you want:
需要注意的是一个完全合格的URL包括查询字符串和额外的路径是一个URI实例,而不是字符串。您可以使用UriBuilder.Query属性提取查询字符串参数(S):
Note that a fully qualified URL including querystring and extra path is a Uri instance rather than string. You can use the UriBuilder.Query Property to extract the query string parameter(s):
您需要解析URI中的接收站点的页面的Page_Load方法。
You need to parse the URI in the Page_Load method of the receiving site's page.
这篇关于查找引用URL和解析的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!