为ajax ASP开发调试窗口的最佳方式是什么?净MVC应用程序

时间:2022-08-26 20:49:35

While developing my ASP.NET MVC, I have started to see the need for a debugging console window to assist in figuring out what is going right and wrong in my code. I read the last few chapters of the Pro Asp.net MVC book, and the author details how to use http modules to show page load/creation times and linq to sql query logs, both of which I definitely want to be able to see. However, since I am loading a lot of small sections of my page individually with ajax I don't want the debug information right there in the middle of my screen.

在开发我的ASP。NET MVC,我已经开始看到需要一个调试控制台窗口来帮助了解我的代码中哪些地方是正确的和错误的。我阅读了Pro Asp.net MVC的最后几章,作者详细介绍了如何使用http模块来显示页面加载/创建时间和linq到sql查询日志,这两个我都希望看到。但是,由于我正在用ajax单独加载页面的许多小部分,所以我不希望在屏幕中间显示调试信息。

So the idea I came up with was to have a separate browser window (open-able by a link or some javascript) with a console log, that can contain logged entries both from javascript and from the asp.net mvc run. The former should be relatively easy, but I'm having trouble coming up with a way to log the asp.net information in ajax requests.

所以我想到的想法是有一个独立的浏览器窗口(可以通过链接或javascript打开)和控制台日志,它可以包含来自javascript和asp.net mvc运行的日志条目。前者应该相对容易一些,但是我很难想出在ajax请求中记录asp.net信息的方法。

The direction I have been thinking of going is to create an httpmodule (like the Pro MVC book does), and have that module contain some script tags that append the javascript's log to console calls with the messages. The issue I see with this is finding a way to get the log messages from the controller's action methods to the httpmodule's methods. The only way I see to do this is with a singleton, but I'm not sure if singletons are bad practice for a stateless web application.

我一直在考虑的方向是创建一个httpmodule(就像Pro MVC book那样),并让该模块包含一些脚本标记,这些脚本标记将javascript的日志附加到使用消息的控制台调用。我看到的问题是找到一种方法,将日志消息从控制器的操作方法获取到httpmodule的方法。我看到的唯一的方法是使用单例,但是我不确定单例对于无状态web应用程序来说是否是不好的实践。

Furthermore, it seems like if I return json with my ajax calls (instead of pure html) then that won't work at all unless there is a way to add data to an existing json structure inside the httpmodule.

此外,如果我使用ajax调用返回json(而不是纯html),那么这似乎根本就不能工作,除非有一种方法可以将数据添加到httpmodule中的现有json结构中。

How does everyone else handle this type of debugging in heavily ajax applications?

在大量的ajax应用程序中,其他人如何处理这种类型的调试?

For reference, the javascript library I am using is jquery.

作为参考,我使用的javascript库是jquery。

1 个解决方案

#1


2  

Why not Firebug or Fiddler? (or both? Together they do 99% of what you need.)

为什么不是Firebug或者Fiddler呢?(或两者?它们合在一起就能满足你99%的需求。

#1


2  

Why not Firebug or Fiddler? (or both? Together they do 99% of what you need.)

为什么不是Firebug或者Fiddler呢?(或两者?它们合在一起就能满足你99%的需求。