Created
March 20, 2012 20:05
-
-
Save cbcwebdev/2140744 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ConnectionFactory | |
{ | |
public static IDbConnection Create() | |
{ | |
var connection = new SqlConnection(ConfigurationManager.ConnectionStrings["default"].ConnectionString); | |
connection.Open(); | |
return new ProfiledDbConnection(connection, MiniProfiler.Current); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected void Application_BeginRequest() | |
{ | |
if(IsProfiledRequest) | |
MiniProfiler.Start(ProfileLevel.Verbose); | |
} | |
protected void Application_EndRequest() | |
{ | |
if(IsProfiledRequest) | |
MiniProfiler.Stop(); | |
} | |
protected bool IsProfiledRequest | |
{ | |
get | |
{ | |
bool shouldProfile; | |
Boolean.TryParse(Request["profiler"], out shouldProfile); | |
return (Request.IsLocal || shouldProfile); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment