简体   繁体   English

ASP.NET - Razor。 即时重写 URL

[英]ASP.NET - Razor. Rewrite URL on the fly

Is it possible to rewrite URL on the fly, only when a part of the server code has already been processed for the "raw" URL and it becomes clear the parameters must not be revealed to the user?是否可以在运行中重写 URL,仅当已经为“原始” URL 处理了部分服务器代码并且很明显不能向用户透露参数时? Like, I want to proccess all the GET parameters in my page code on the server and create a tracking record in the database, then serve the user the page but change URL to parameterless in the browser.就像,我想在服务器上处理我的页面代码中的所有 GET 参数并在数据库中创建跟踪记录,然后为用户提供页面但在浏览器中将 URL 更改为无参数。

I guess all the web.config referred module techniques won't work as they offer URL rewriting before request is passed to the page code on the server.我猜所有 web.config 引用的模块技术都不起作用,因为它们在请求传递到服务器上的页面代码之前提供 URL 重写。 But it comes in my case that I receive an ugly URL from google adwords clicks and I do like it tracked 'as is' in my database, and I do certainly not like it show to user in her brower's bar.但在我的情况下,我从谷歌广告点击中收到了一个丑陋的 URL,我喜欢它在我的数据库中“按原样”跟踪,我当然不喜欢它在她的浏览器栏中显示给用户。

At the same time I would like to keep URL unchanged without applying the URL rewrite most of the time unless some particular parameter shows up in it (like ref=adwords) so that any paramter written by hand or posted back would be displayed in the address bar.同时,我想保持 URL 不变,而不应用 URL 重写大部分时间,除非其中出现某些特定参数(如 ref=adwords),以便手写或回发的任何参数都会显示在地址中酒吧。

Is it possible to do so by any means?有可能通过任何方式这样做吗?

Have you considered writing an ActionFilter that would (if your controller or method is decorated with it) intersect your initial request, do all the necessary processiong and then redirect back to the requested page only indicating, that processing has been done?您是否考虑过编写一个ActionFilter (如果您的 controller 或方法用它装饰)与您的初始请求相交,执行所有必要的处理,然后重定向回请求的页面,仅表明该处理已完成?

This would be my first thought.这将是我的第一个想法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM