How to profile an ASP.NET Core Website?

Has anyone figured out how to profile an ASP.NET Core website from Visual Studio? There is no straightforward way (like profiling an ordinary .exe through the Visual Studio Add-in), and the various things I've tried hasn't given any success.

I've tried searching for a guide or tutorial both on the website and in the forums and browsing/searching through the documentation. But nothing has shown up.

When I start the application from Visual Studio Add in (Choosing "Profile performance") it starts up with the .dll prefilled and starts profiling, but nothing happens, it just says "Waiting for Client" down in the left corner. I tried starting the debugging session in Visual Studio (while the proiler says Waiting for client) but the process starting is not profiled.

I then tried to profile the exe-file directly, located in bin\Debug\net452\win7-x86, (instead of the dll) as the website can be started from command line. But the appsettings etc and other files are not located in this directory, so it's not able to start correctly and pick up my connection strings etc.

I then tried to start the website via ".NET executeable" by executing "dotnet.exe" and supplying the parameters 'run --environment "Development"', but then the Profiler crashes (I sent the crash report to RedGate).

So... I'm pretty lost in how to profile my ASP.NET Core website. Any suggestions?


  • rsrs Posts: 13 Bronze 2
    I'm stuck on this too. Is there anyone from red-gate listening that could clue us in on the approach to profiling ASP.NET Core sites. Perhaps the support isn't there just yet in ANTS which wouldn't be ideal, but if you could confirm then at least we would know the score.
  • joebonejoebone Posts: 3 New member
    We also ran into the crash issue with self hosted aspnet core sites, and sent the crash reports. Any feedback would be appreciated.
  • Jessica RJessica R Posts: 1,319 Rose Gold 4
    Hi all,

    So sorry for the delay on this!

    When you build your application, the.NET tooling should have built a WebApplicationName.dll with the Main method compiled into it which is linked as the entry point--if you use the ".NET Core application" profiler option and point it to this dll, then the profiling session should start.

    I am though also seeing some issues in which starting a profiling session from the VS add-in fails because it tries to start the profiling session with the wrong file and I am looking into this.

    Can you kindly confirm for me though--what file does it use to start the profiling session for you when you "profile performance" (the file should be shown in the title bar)? And can you please also let me know the error message that comes up when you try "Launch performance profiler" so that I can track down these reports? @JanA @rs @joebone

    Thank you!

    Jessica Ramos | Product Support Engineer | Redgate Software

    Have you visited our Help Center?

  • joebonejoebone Posts: 3 New member
    @Jessica R This is a self hosted/kestrel site - I have tried both with compiling to a windows target, or having it open the dll itself. The profiling is launched from the standalone ants profiler. In both cases, it is the application itself that crashes, in kernelBase.dll, and looking at the call stack, it appears to be from t
    he RcFrameConsolidation in nt.dll ( attached screenshots ).

    As this is 100% reproducible, if you'd like, I can give you the binaries directly... although obviously posting on a public forum would be frowned upon =)
    Launch settings:


    Debugging that exception :

    Then when clsoing ants:

    Evidentally, when just running the application (via "dotnet dllname.dll") and using the appropriate environment variables, it works fine - confirmed and tested both on windows (7, 10, server 2012 and server 2016), and debian 8. So there is something in the way the profiler loads itself and dotnet.exe that causes this behaviour. Speaking of environment variables, is there any way to specify them within a profiling session for dotnet core apps?
  • JanAJanA Posts: 5 Bronze 1
    Hi @Jessica R
    I have started from scratch with an empty project to replicate the issue and still have the problem.

    When I choose "Profile performance" the file in the title bar is Projects\RedGateTest\RedGateTest\bin\Debug\net452\win7-x86\RedGateTest.dll. See the screenshot. The problem here, is that no application is starting, it is just "Waiting for client".

    Looking for another solution I then try to start my application via the dotnet run method instead. Start the profiler via "Launch ANTS Performance Profiler" and then start configuring it like in this screenshot (both with and without the --environment argument):

    But then the application crashes, like mentioned before.

    The reason that I need to supply commandline arguments and/or environment variables, is that this is the way core differentiates configurations. That way you can have different configurations (connectionstrings etc) for Development and Production environment. See

    The way core does this, is via an environment variable called ASPNETCORE_ENVIRONMENT that needs to be set, so that is loads the correct appsettings.json depending of the environment. Visual Studio manages this via profiles in the launchSettings.json and makes the user easily choose which environment to run.
    Unfortunately, running your application/website from the commandline via "dotnet run" is that if no environment is supplied, it defaults to Production, which (IMHO) is not desireable. You can, via a little workaround code, make your application get the environment from the Command line, so that you can start your application by calling "dotnet run --environment=Development". This is a bit annoying, but something that only needs to be done once for each application/website you develop. (See the section "CommandLine configuration provider" in the above url for instructions how to do it).

    The best and easiest thing would be if "Profile performance" could obey or integrate with the launchSettings.json like Visual Studio does. That way everything is configured correctly and no need for special lines of codes to get it to work. Then ANTS Performance Profiler would also work out-of-the-box with standard core projects and would be easier for users to get started with profling.

    I will reply to your support-ticket with the entire project zipped, to you can test it out.
  • Jessica RJessica R Posts: 1,319 Rose Gold 4
    Hi all,

    I unfortunately still haven't been able to reproduce this, though I'm sure I'm just missing something.

    @JanA We unfortunately never received your files- in case your message got blocked due to the attachment, I've just sent you a link that you can upload to instead.

    @joebone If you can still share your files with us as well it would be much appreciated. You can zip them up and send them to [email protected] (If the file exceeds 20mb though, please just send an email to [email protected] to let me know and I'll create an upload link for you also.)

    Thank you both as well for the info on needing to set the environment variables--I've passed this directly to our developers and my apologies that there isn't a way to set this through the profiler at the moment!

    Jessica Ramos | Product Support Engineer | Redgate Software

    Have you visited our Help Center?

  • JanAJanA Posts: 5 Bronze 1
    Hi @Jessica R

    I have sent the files via the supplied upload-link.
  • joebonejoebone Posts: 3 New member
    Hi, any progress diagnosing this issue?
  • JanAJanA Posts: 5 Bronze 1
    Yes, it would be interesting to know the status of this.

    With 150+ views on this question/issue (which is 10 times more than the average views of other questions in this category), it seems that this is a problem for a lot of people.

    I look forward to profile my ASP.NET Core website.
  • JanAJanA Posts: 5 Bronze 1
    Another month have passed and now 250+ views on the question. Any progress on this issue? @Jessica R ?
  • rsrs Posts: 13 Bronze 2
    Can someone from RedGate please provide an update on this issue. Simply going silent when there is clearly an issue here is not going to create many happy customers.
  • We're currently investigating this. I can't give an ETA yet I'm afraid, but we are investigating it.

    Jessica is currently unavailable hence the lack of updates, apologies for that.
    Have you visited our Help Centre?
  • talktotroytalktotroy Posts: 1 New member
    Any Updates please.
  • Russell DRussell D Posts: 1,324 Diamond 5
    edited March 28, 2018 8:52AM
    This should be taken care of by the next release, which should be in 2-3 weeks. As with anything this is subject to testing and may change.
    Have you visited our Help Centre?
  • scheelingsscheelings Posts: 1 New member
    Is this fix already released?
  • Jessica RJessica R Posts: 1,319 Rose Gold 4
    Hi all,

    So sorry again for the delays! This is now fixed and you can also now specify environment variables for the profiled application.

    Jessica Ramos | Product Support Engineer | Redgate Software

    Have you visited our Help Center?

Sign In or Register to comment.