使用 ASP.NET MVC 3 和 Razor 视图进行用户跟踪
在 ASP.NET MVC 3 中使用 Razor 视图时,在整个网站上实现用户跟踪的最佳方法是什么。
在 Webforms 中,我会在母版页中放置一些代码以使用 cookie 并记录人们访问我的网站上的每个 url一个数据库,但我不确定在 ASP.NET MVC 中的何处实现此代码。
What's the best way to implement user tracking throughout your web site when using Razor views in ASP.NET MVC 3.
In webforms I'd put some code in the masterpage to use a cookie and log each url on my site that a person visits in a database, but I'm not sure where to implement this code in ASP.NET MVC.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我想最好的方法是创建一个全局操作过滤器,并跟踪那里的访问。
创建一个动作过滤器属性:
在全局asax中将其注册为全局过滤器:
仅此而已。好的?
I guess the best way to do this is to create a Global Action Filter, and track visits there.
Create an action filter attribute:
Register it as a global filter in global asax:
That's all. Nice?
我不会用 Razor 视图做任何事情。
您将需要构建一个 ActionFilter 并将其附加为 全局过滤器 。让它为您完成所有工作。
更多好书...
I wouldn't do any of it with Razor views.
You will want to build an ActionFilter and attach it as a GlobalFilter. Let it do all the work for you.
More good reading...