tags:

views:

127

answers:

4

I'm creating a site, and I need to create a basic API. Unfortunately I have no idea where to start.

My site will basically keep track of errors from other users' ASP.NET sites, and they can come to my site to filter through them, search through them, comment, resolve, etc. I need to create an API, where the user can insert a few lines of code in the Application_Error event in the global.asax file, and it will pass an exception object to my site to be stored.

It's the communicating between their site and my site that I don't understand and have no experience with.

Does anyone know of a good tutorial for creating a basic API like this?

+2  A: 

You can create a page, handler, etc that receives data as an POST. Like twitter and other sites does.

Zote
That's exactly what I'd like to do. Do you have any tutorials or code samples?
Steven I don't have in my hands, but you can find using bing or google. If my answer is exactly what you need, please, mark it as answered.
Zote
A: 

Why make the API when there already is an API for this. You can use ASP.NET's webevents framework to catch this? Basically, each site could log the errors to a database, then your management app could read from the database for each site.

Check out ASP.NET health monitoring for more details.

Wyatt Barnett
Health monitoring can log errors to an external database on a different server? And if so, how would I hide my connection string info from the client?
It wasn't clear this was a requirement. You can drop your connection info (and specialized health monitoring configuration) in the machine's web.config, which the client's shouldn't be able to hit directly. Connectionstring-wise, you should probably be using windows auth anyhow so them getting the info won't hurt too much.
Wyatt Barnett
A: 

It seems like you are trying to build a bug tracker. If you want to build it from scratch just for fun then check out health monitoring system of ASP.NET 2.0. Also, check out ELMAH it is super awesome.

Here is a screencast showing off how easy it is to setup ELMAH:

http://www.highoncoding.com/Articles/458%5FPlugging%5FElmah%5Finto%5FWeb%5FApplication%5Fto%5FCatch%5FUnhandled%5FExceptions.aspx

azamsharp
A: 

Just to re-iterate what's already been said, what you're trying to create is a web service - you have a number of options for implementing this from what basically amounts to a page you can post to through to notionally more complicated soap based stuff. I say notionally because if you're using ASP.NET at both ends then creating and consuming a service is relatively trivial.

For new development its suggested that you want to use WCF - which I find slightly harder than ASP.NET web services - basically run new project in Visual Studio and you'll get a framework which you really won't have to change much to create a service. At the client end there's a nice "add service" wizard that again will do the grunt work for you. Advantage of WCF is that you have more flexibility in the binding i.e. how the calling apps talk to the service.

For deployment I'd wrap your error logging code into an assembly - your users then just need to reference the assembly, and make a call setting the URL of the logging service and passing the error details.

For reference, you might want to go look at http://exceptioneer.com/ which is a service that does something similar to the setup you're trying to provide.

Murph