I have been following the setup shown on
I am referencing the EntityFramework v4.3.1
NuGet Package in my Web Application just to get MiniProfiler
working but the EF .edmx
and generated model is in a separate referenced project.
I am also using
MiniProfile.EF v2.1.0
MiniProfiler v2.1.0
My web applications global.asax.cs
looks like this
public class Global : HttpApplication
{
private void Application_Start(object sender, EventArgs e)
{
MiniProfilerEF.Initialize();
//MiniProfilerEF.InitializeEF42();
// Code that runs on application startup
InitProfilerSettings();
}
protected void Application_BeginRequest()
{
if (Request.IsLocal)
{
MiniProfiler.Start();
}
}
private void Application_End(object sender, EventArgs e)
{
MiniProfiler.Stop();
}
private void InitProfilerSettings()
{
// some things should never be seen
var ignored = MiniProfiler.Settings.IgnoredPaths.ToList();
ignored.Add("/Styles/");
ignored.Add("/Scripts/");
ignored.Add("/files/");
ignored.Add("/images/");
MiniProfiler.Settings.IgnoredPaths = ignored.ToArray();
MiniProfiler.Settings.SqlFormatter = new StackExchange.Profiling.SqlFormatters.InlineFormatter();
}
}
I have added a handler into my web.config
as shown below
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<handlers>
<add name="MiniProfiler" path="mini-profiler-resources/*" verb="*" type="System.Web.Routing.UrlRoutingModule" resourceType="Unspecified" preCondition="integratedMode" />
</handlers>
</system.webServer>
I have added the below to my Master page at the end before closing the body tag
<%= StackExchange.Profiling.MiniProfiler.RenderIncludes() %>
I could only setup a context with a profiled connection by doing the below , because otherwise I was getting a runtime error when using an EntityConnection
during the execution of a LINQ query on the DBContext.
//var _modelContext = new Entities();
// ConfigurationManager.ConnectionStrings["Entities"].ConnectionString
//var profiledConnection = new EFProfiledDbConnection(new Entities().Connection, MiniProfiler.Current);
var profiledConnection = new EFProfiledDbConnection(new SqlConnection(ConfigurationManager.ConnectionStrings["EntitiesSql"].ConnectionString), MiniProfiler.Current);
var _modelContext = ObjectContextUtils.CreateObjectContext<Entities>(profiledConnection);
All of this seems to work and I can run my application locally and I can view the page source and see this script block, and in Chrome I can select the include.js link and see the contents
<script async type="text/javascript" id="mini-profiler" src="/mini-profiler-resources/includes.js?v=xwYPDDH1blvqmxgsBweNC++H7CFU3KGQ+zFcVlJPsXw=" data-version="xwYPDDH1blvqmxgsBweNC++H7CFU3KGQ+zFcVlJPsXw=" data-path="/mini-profiler-resources/" data-current-id="adf7a5f4-482d-4f65-b09e-e3c59b157134" data-ids="adf7a5f4-482d-4f65-b09e-e3c59b157134" data-position="left" data-trivial="false" data-children="false" data-max-traces="15" data-controls="false" data-authorized="true" data-toggle-shortcut="Alt+P" data-start-hidden="false"></script>
however when viewing the Console in Chrome I get the message of
POST http://localhost:54406/mini-profiler-resources/results 404 (Not Found)
I was hoping the addition of the relevant handler would have fixed my problem :( but it hasn't.
Any help is appreciated.