将传入查询字符串添加到所有传出链接/流量 C#
如果我有一个名为 www.testsite.com 的页面,并且我使用 url 中的查询字符串链接到该页面,是否可以以某种方式将相同的查询字符串附加到所有传出链接/流量?
例如,假设我链接到该页面,如下所示 www.testsite.com?parameter1=somevalue 然后,在该页面上,我单击一个链接,例如 google,我希望传递参数,以便 url 为 www.google.com?parameter1=somevalue。
我知道如何手动执行此操作,但是有什么办法可以将其自动附加到网址吗?就像在发生之前捕获传出请求并添加参数一样?
谢谢!
埃里克
If i have a page called www.testsite.com and I link to that page using a querystring in the url, is it possible to attach that same querystring to all the outgoing links/traffic somehow?
For instance, say I link to that page like this www.testsite.com?parameter1=somevalue
And then, on that page I click a link to for instance google, and I would like the parameter to be passed so the url would be www.google.com?parameter1=somevalue.
I know how to do this manually, but is there someway it can be appended to the url automatically? Like catch the outgoing request before happening and add the parameter?
Thanks!
Eric
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可以使用 javascript 或使用 jQuery 的 javascript 非常简单地完成此操作,
您可以开始使用
如果您想要非 jQuery 解决方案,
jQuery,您可以仅使用 javascript 来研究绑定事件http://www.digimantra.com/tutorials/change-onclick-function-anchor-tag-javascript/
http://forums.techarena.in/software-development/1308647.htm
you could do this pretty simply with javascript or javascript using jQuery
that should get you started
if you wanted a non-jQuery solution you can look into binding events using javascript only
http://www.digimantra.com/tutorials/change-onclick-function-anchor-tag-javascript/
http://forums.techarena.in/software-development/1308647.htm
您可以通过 httpmodule 实现拦截过滤器,该模块会修改您发送回客户端的 html。有关详细信息,请参阅:http://msdn.microsoft.com/en-us /library/ff649096.aspx
还有一些示例:
Http 响应过滤器
SO:获取要修改的 HTML 内容
You can implement an intercepting filter through an httpmodule which modifies the html you emit back to the client. For more details see: http://msdn.microsoft.com/en-us/library/ff649096.aspx
And a few more examples:
Http Response Filter
SO: Get HTML content for modification
除非您有一个输出传出链接的中心位置,否则您必须手动执行此操作(可能 Visual Studio 搜索/替换可以在此处提供帮助,但我会小心,因为您最终可能会更改您不想更改的链接)。
Unless you have a central location where you output the outgoing links, you will have to do this manually (possibly the visual studio search/replace can help here, but I would be careful as you may end up changing links you didn't want to).
您可以使用以下方式使用查询字符串参数
您可以循环遍历所有查询字符串参数,这
只是基本想法。但是您可以在不知道名称的情况下循环遍历参数。
You can use following to use Query String parameters
You can loop through all your query string parameters like this
its just basic idea. But you can loop through parameters without knowing the names.