简体   繁体   English

ASP.NET缓存的Aspx页面和IIS日志

[英]ASP.NET cached aspx page & IIS logs

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? 有没有办法找出ASP.Net运行时是否已提供ASPX页面的缓存副本或实际上已经历页面生命周期?

Here is my problem: 这是我的问题:

I'm seeing many entries in my IIS log files that were served successfully (200 OK) . 在IIS日志文件中看到许多已成功提供服务的条目(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. 在Session_Start和Application_BeginRequest()事件中有一个相应的日志记录代码(Log4Net API),该事件正在将每个请求记录到数据库中,并提供了更多详细信息。 I'm not seeing any corresponding entries in my SQL DB for some cases that should have been created by Log4Net code. 对于某些本应由Log4Net代码创建的情况,我在SQL DB中没有看到任何对应的条目。

Are there any logs available to find out if a cached copy was served by .NET worker process? 是否有任何日志可用来查找.NET工作进程是否提供了缓存的副本? Moreover, if my logging code would throw an exception, won't that show up as 500 in IIS logs? 此外,如果我的日志记录代码将引发异常,那么在IIS日志中不会显示为500?

The code is on Windows 2008 Server, IIS 7. 该代码位于Windows 2008 Server IIS 7上。

PS: If coding assembly resolve event and logging into a database can help track this? PS:如果编码程序集解决事件并登录数据库可以帮助跟踪此事件? Can somebody point me to an example? 有人可以指出一个例子吗?

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. 要打开跟踪,请打开您的web.config并找到...标签。 Set enabled="true", save the web.config, then you can go to http://{your site}/trace.axd and view the page trace events. 设置enabled =“ true”,保存web.config,然后您可以转到http:// {您的站点} /trace.axd并查看页面跟踪事件。

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 这是来自MS的有关此强大功能的更多信息: http : //msdn.microsoft.com/zh-cn/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. 您还可以在代码中使用Trace.Write或Trace.Warn写入跟踪输出。 It's a great way to add a bit of debugging code that will only run when Tracing is enabled. 这是添加仅在启用跟踪时才运行的调试代码的好方法。

HTH, Lance HTH,兰斯

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

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