可否知道当前的IIS正在处理哪个网页?

keenx 2004-08-30 06:59:28
可否利用.net来监视当前IIS正在处理哪个网页或访问哪个文件呢?
请教各位高手,谢谢。
...全文
204 18 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
18 条回复
切换为时间正序
请发表友善的回复…
发表回复
The123 2004-08-31
  • 打赏
  • 举报
回复
MARK
速马 2004-08-31
  • 打赏
  • 举报
回复
难道你把asp和aspx配置在同一个虚拟目录运行?

如果是非ASP.NET的动态程序
那就用思归说的第一种办法,写一个isapi程序
keenx 2004-08-31
  • 打赏
  • 举报
回复
可是asp不可以这样映射啊。
速马 2004-08-31
  • 打赏
  • 举报
回复
同思归
可以考虑通过HttpModule实现
wangdequan1024 2004-08-31
  • 打赏
  • 举报
回复
UP
KEYMEN 2004-08-31
  • 打赏
  • 举报
回复
up
xiaomaoy 2004-08-31
  • 打赏
  • 举报
回复
UP
ELONGSSS 2004-08-31
  • 打赏
  • 举报
回复
minjian_ken@21cn.com
速马 2004-08-31
  • 打赏
  • 举报
回复
打错了:verb="*.html,*.aspx" path="*" --> verb="*" path="*.html,*.aspx"

在IIS的脚本映射中还需要添加一条才能运行
就是把html交给aspnet_isapi.dll执行
速马 2004-08-31
  • 打赏
  • 举报
回复
还不明白的话可以留下邮箱,我给你示例代码
速马 2004-08-31
  • 打赏
  • 举报
回复
如果是需要监视所有页面,可以让HttpHandler和HttpModule配合工作

ASP.NET默认带有执行ASP.NET页面(比如aspx)的Handler
但是如果需要让其他页面也让HttpModule处理,则需要重新配置这个Handler
HttpModule的模型可以看这里:http://www.15seconds.com/graphics/issue/020417_01.jpg

所以比如你需要监视所有aspx页面和html页面,需要这么配置web.config:
<httpModules>
<add type="HttpModuleNamespace,AssemblyName" name="MyModule"/>
</httpModules>
<httpHandlers>
<add type="System.Web.UI.PageHandlerFactory" verb="*.html,*.aspx" path="*"/>
</httpHandlers>
keenx 2004-08-31
  • 打赏
  • 举报
回复
分析日志是可以,不过我的日志的时间和系统时间不一样。
而且分析日志不可以实时,就算我每隔一分钟去读日志,那样会很耗费资源啊。
keenx 2004-08-31
  • 打赏
  • 举报
回复
不是说HttpModule只可以实现对.net页面的监控吗?
可以通过配置就可以监控所有网页了吗?请教速马。
nnfzj 2004-08-31
  • 打赏
  • 举报
回复

日志就是起这个作用的.

速马 2004-08-31
  • 打赏
  • 举报
回复
虚拟目录内的所有网页都可以监控
看你怎么配置
keenx 2004-08-31
  • 打赏
  • 举报
回复
可是只处理监控.net的网页作用不大啊。
saucer 2004-08-30
  • 打赏
  • 举报
回复
if you mean any files (.html/.gif/....), you probably should write an ISAPI DLL, but it is unlikely you can write it in C#, see

http://www.codeproject.com/isapi/

if you mean to monitor ASP.NET files, then you can write a HttpModule, see

How To Create an ASP.NET HTTP Module Using Visual C# .NET
http://support.microsoft.com/default.aspx?scid=kb;EN-US;307996
noahart 2004-08-30
  • 打赏
  • 举报
回复
我想到了一个办法。我的机子是2000,在IIS默认web站点的属性里面有一个"启用日志记录"
再点它的属性,可以看到日志文件的路径.
在system32文件夹下LogFiles里面可以找到日志文件.
如:
#Software: Microsoft Internet Information Services 5.0
#Version: 1.0
#Date: 2004-08-26 11:02:25
#Fields: time c-ip cs-method cs-uri-stem sc-status
11:02:25 168.126.79.199 GET /scripts/..%5c%5c../winnt/system32/cmd.exe 500
11:51:39 211.146.112.211 GET /proxy-scanner.php 404
#Software: Microsoft Internet Information Services 5.0
#Version: 1.0
#Date: 2004-08-26 15:06:51
#Fields: time c-ip cs-method cs-uri-stem sc-status
15:06:51 127.0.0.1 GET /WebApplication1/vs134615137629657982_tmp.htm 200
15:06:51 127.0.0.1 GET /_vti_inf.html 200
15:06:57 127.0.0.1 POST /WebApplication1/_vti_bin/shtml.dll 200
15:06:57 127.0.0.1 POST /WebApplication1/_vti_bin/_vti_aut/author.dll 200
15:06:58 127.0.0.1 POST /WebApplication1/_vti_bin/_vti_aut/author.dll 200
15:07:11 127.0.0.1 GET /WebApplication1/get_aspx_ver.aspx 404
15:07:27 127.0.0.1 GET /ASPxGrid/Images/bbPrev.gif 304
15:07:27 127.0.0.1 GET /ASPxGrid/Images/1x1.gif 304
15:07:27 127.0.0.1 GET /ASPxGrid/Images/bbFirst.gif 304
15:07:27 127.0.0.1 GET /ASPxGrid/Images/bbPrevpage.gif 304
15:07:27 127.0.0.1 GET /ASPxGrid/Images/bbPgsize.gif 304
15:07:27 127.0.0.1 GET /ASPxGrid/Images/bbNextpage.gif 304
15:07:27 127.0.0.1 GET /ASPxGrid/Images/bbLast.gif 304
15:07:27 127.0.0.1 GET /ASPxGrid/Images/bbIns.gif 304
15:07:27 127.0.0.1 GET /ASPxGrid/Images/bbNext.gif 304
15:07:27 127.0.0.1 GET /ASPxGrid/Images/bbEdit.gif 304
15:07:27 127.0.0.1 GET /ASPxGrid/Images/bbDel.gif 304
15:07:27 127.0.0.1 GET /ASPxGrid/Images/bbRefresh.gif 304
15:29:12 127.0.0.1 DEBUG /WebApplication1/WebForm1.aspx 401
15:29:15 127.0.0.1 DEBUG /WebApplication1/WebForm1.aspx 200
15:29:25 127.0.0.1 GET /WebApplication1/WebForm1.aspx 200
15:29:34 127.0.0.1 DEBUG /WebApplication1/WebForm1.aspx 200
15:30:28 127.0.0.1 DEBUG /WebApplication1/WebForm1.aspx 200
15:30:32 127.0.0.1 GET /WebApplication1/WebForm1.aspx 200
15:30:38 127.0.0.1 DEBUG /WebApplication1/WebForm1.aspx 200
这里看到的是时间,客户端IP,方法,URI资源和协议状态.
同时也可以扩充日志的选项,把如日期,用户名,服务器名,服务器IP和端口等加到日志文件里面.
你要做的就是访问这些日志文本文件,把它解析出现显示在网页上!

111,094

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧