GurdeepS
GurdeepS

Reputation: 67213

Catching errors in an ASP.NET webpage from winforms

I am writing a WinForms app which will execute some web UI tests written in a web testing framework.

Is there a way I can get the error on the page being tested (I specify the page through a method parameter) without screenscraping the page? For example, if it throws:

A potentially dangerous Request.QueryString value was detected from the client

How can I detect this?

EDIT:

One way would be to scrape just the title.

Upvotes: 2

Views: 236

Answers (2)

Irwin
Irwin

Reputation: 12819

What about trapping the error at the Application level (with a global handler in .asax) and sending the exceptions data to a db? Which you can then query.
Hmm, or even, implementing a WCF dual binding, that you call the clients listening on, when an error occurs. Your windows form can be a proxy waiting for notifications. But maybe, that might not be a good idea, as you would want to have your test, separate from your application. What about using something like Enterprise library to log to an MSMQ, which you can be listening on via the windows form?

EDIT - the ELMAH suggestion above looks good as well

Upvotes: 1

TheTXI
TheTXI

Reputation: 37875

I would actually suggest you look into something called ELMAH. If you put ELMAH on your ASP.NET website it will automatically log and handle all the exceptions that get thrown by your app as you are testing it. You can have it store all the entires as XML files or in a database. You can also have it email you directly with a copy of the Yellow Screen of Death (including stack trace).

This would be a lot easier for you then trying to program the same functionality into your winforms app. Just use your app to beat the ASP.NET site up and let ELMAH handle the error logging.

Upvotes: 3

Related Questions