MiniProfiler Start and StartNew not Working as per Documentation

1.2k Views Asked by At

I am following these instructions to attach the MVC MiniProfiler to my project.

Steps taken:

  • Install-Package MiniProfiler.Mvc5 -IncludePrerelease
  • using StackExchange.Profiling in Global.asax.cs
  • MiniProfiler.Start() in Application_BeginRequest

But Visual Studio complains that

'MiniProfiler' does not contain a definition for 'Start`

So I checked the suggested example file and tried to imitate that but with pretty much the same results, ie

'MiniProfiler' does not contain a definition for 'StartNew`

What is going on here? Does this documentation need to be updated?

1

There are 1 best solutions below

0
On BEST ANSWER

I just found the answer! Assuming we are migrating from an old Miniprofiler version to MVC5 version.

For "Start" replace:

MiniProfiler.Start();

With:

MiniProfiler mp = MiniProfiler.StartNew();

This will now give you more the sence that we are creating a new instance on the session. For "Stop" replace:

MiniProfiler.Stop();

With:

MiniProfiler.Current.Stop();

Any action will now required to call "MiniProfiler.Current.xxx" to access that created MiniProfiler and do stuff. Or depending on how and where you are using it, you can call the saved MiniProfiler mp that you created earlier.