Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I use MiniProfiler to instrument an ASP.NET MVC WebApi website?

The ASP.NET MVC website I'm working on has some (Controller-derived) "user" pages and some (ApiController-derived) "api" pages.

The site uses MiniProfiler to instrument the "user" pages, and I really like what it does. I'd like to have the same or similar functionality in the "api" pages - specifically, a record of the SQL statements that were executed, and how long everything took.

I saw this link which looked promising, where the URL of the entry point is simply entered into the browser address bar, but that's using the default view that comes out of the box with ASP.NET MVC WebApi. My own URLs return an XML document (or JSON response).

Also, I'd prefer something that will allow me to get away from the browser, since my real-life API calls are initiated by another program, and I'd like to be able to record information about a whole session rather than just a single request.

Any advice?

like image 969
Gary McGill Avatar asked Jul 29 '13 15:07

Gary McGill


1 Answers

You can have MiniProfiler log it's results to a database instead of disposing of the results. At that point you'll be able to look back at the performance over time (against a session or an end point).

Add:

MiniProfiler.Settings.Storage = new SqlServerStorage("connection string here");

to your settings and it should start logging to the database.

like image 140
Steven V Avatar answered Oct 09 '22 13:10

Steven V