Global.asax和HTML [英] Global.asax and HTML

查看:65
本文介绍了Global.asax和HTML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

不知道这是否是一个愚蠢的问题...:P

我正在尝试为我的网站写一个在线访客"计数器.该代码工作100%.我的问题是这样的:

访客从各种不同的进入页面(都是纯HTML)访问我的网站.访问html页面而不是aspx页面时,global.asax文件是否可以运行并增加我的计数器?

为了进一步说明,global.asax页在创建用户会话时更新应用程序变量([usersOnline] + 1),并在会话结束时更新-1.


谢谢!

解决方案

即使在HTML页面内,您也可能会强制访问aspx页面-选择出现在每个页面上的元素(可能是背景图片或徽标)并将URL替换为一个非常轻巧的aspx页面的链接,该页面仅读取/呈现相关图像(需要设置内容类型和缓冲输出等),以便您将图像呈现为jpg/gif等. 文件).然后您在global.asax中的会话事件应该会正常运行.

毫无疑问,您可以使用javascript/AJAX调用来提出替代方案,但是即使对于没有javascript的客户端,上述方法也可以使用.通常..不,它不会增加bcz iis不会将任何html/jpeg请求传递到您的asp.net应用程序.


Hi everybody,

Don''t know if this is a silly question... :P

I am trying to write a "visitors online" counter for my website. The code is working 100%. My question now is this:

Visitors are accessing my website from various different entry pages, which are all plain HTML. Will the global.asax file run and increment my counter when you access html pages, and not aspx pages?

Just for more clarification, the global.asax page updates an application variable ([usersOnline] + 1) when a user session is created, and -1 when the session ends.


Thank you!

解决方案

You might force access to an aspx page even within an HTML page - pick an element (maybe a background image or logo) that appears on every page and replace the URL with a link to a very lightweight aspx page that just reads / renders the relevant image (need to set content type and buffer output etc. etc. so that you render the image just as if it was a jpg/gif etc. file). Then your session events in global.asax should fire fine.

No doubt you could come up with alternatives using javascript / AJAX calls, but the above will work even for clients that don''t have javascript.


Based on IIS settings it will happen. typically.. No it wont get increased bcz iis wont pass any html/jpeg request to your asp.net application.


这篇关于Global.asax和HTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆