ASP.NET 缓存的 aspx 页面& IIS 日志
有什么方法可以查明 ASP.Net 运行时是否已提供 ASPX 页面的缓存副本或实际上经历了页面生命周期?
我的问题是:
我在 IIS 日志文件中看到许多已成功提供服务的条目 (200 OK)。我在 Session_Start 和 Application_BeginRequest() 事件中有一个相应的日志记录代码 (Log4Net API),它将每个请求记录到我的数据库并包含更多详细信息。对于某些本应由 Log4Net 代码创建的情况,我在 SQL DB 中没有看到任何相应的条目。
是否有任何日志可用于查明缓存副本是否由 .NET 工作进程提供服务?此外,如果我的日志记录代码抛出异常,那么在 IIS 日志中不会显示为 500 吗?
该代码位于 Windows 2008 Server、IIS 7 上。
PS:如果编码程序集解析事件并登录到数据库可以帮助跟踪此事件?有人可以给我举个例子吗?
Is there any way to find out if ASP.Net runtime has served a cached copy of ASPX page or actually went through the page life cycle?
Here is my problem:
I'm seeing many entries in my IIS log files that were served successfully (200 OK). I've a corresponding logging code (Log4Net API) in the Session_Start and Application_BeginRequest() events that is logging every request to my DB with more details. I'm not seeing any corresponding entries in my SQL DB for some cases that should have been created by Log4Net code.
Are there any logs available to find out if a cached copy was served by .NET worker process? Moreover, if my logging code would throw an exception, won't that show up as 500 in IIS logs?
The code is on Windows 2008 Server, IIS 7.
PS: If coding assembly resolve event and logging into a database can help track this? Can somebody point me to an example?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您不想手动添加更多日志记录,那么您可以打开跟踪。要打开跟踪,请打开 web.config 并找到 ... 标签。设置enabled=“true”,保存web.config,然后您可以访问http://{your site}/trace.axd并查看页面跟踪事件。
您可以通过首先查看页面,然后单击离开并返回到该页面,然后检查跟踪以查看记录的事件的差异来测试是否可以看到缓存调用。您应该在第二个页面视图的跟踪中看到缓存获取。
以下是有关 MS 的这一出色功能的更多信息:http:// /msdn.microsoft.com/en-us/library/1y89ed7z(VS.71).aspx
您还可以在代码中使用 Trace.Write 或 Trace.Warn 写入跟踪输出。这是添加一些调试代码的好方法,这些代码仅在启用跟踪时运行。
哈特哈,
槊
If you don't want to manually add more logging, then you could just turn on tracing. To turn on tracing, open up your web.config and find the ... tag. Set enabled="true", save the web.config, then you can go to http://{your site}/trace.axd and view the page trace events.
You can test to see if you can see caching calls by first viewing a page, then clicking away and going back to it, then checking the trace to see the differences in the events that are recorded. You should see cache fetching in the trace of the second page view.
Here's more info about this great feature from MS: http://msdn.microsoft.com/en-us/library/1y89ed7z(VS.71).aspx
You also have the ability in your code to write to the trace output using Trace.Write or Trace.Warn. It's a great way to add a bit of debugging code that will only run when Tracing is enabled.
HTH,
Lance