开发者

Possible to use HttpApplication state in a .NET console app?

I need to quickly write a test console app for testing purposes.

This app is basically the console version of an ASP.NET app.

The original ASP.NET app makes use of the global Application object for storing global data.

How can I get the same functionality of the Application object in my console app? Can I declare an HttpApplication object directly and use it?

NOTE - this app is just for debugging so开发者_开发问答me issues, not production code, so I'm ok if it's not "best practice".


You could just declare a static Dictionary<string, object> in your Program class


I just tried to create a console app project and reference the System.Web namespace where HttpApplication lives and it is not there so that is not an option. Not to get too far into the reasoning behind the Console App but have you considered Unit Tests on the methods you are trying to test or even running up a little web app to test just the functionality you want to test. Without more info, it is hard to offer suggestions.


I think you can add to your solution test project with some classes and methods and send to these methods HttpApplication as a parameter. And then you can use System.Diagnostics.Debug.WriteLine(...) to see the results in the Output window of Visual Studio when you add some specific information for you to WriteLine(...) method.

Hope this will help you with your question! Good luck!

Best regards, Dima.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜