Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9254061
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:22:23+00:00 2026-06-18T11:22:23+00:00

I have a simple web form application that uses a masterpage. I followed the

  • 0

I have a simple web form application that uses a masterpage.

I followed the instructions on how to get mini-profiler working. I get all the stats OK. Now I do not really know how to toggle it on or off.

I thought of using a query string and look for it Application_BeginRequest – If it is there just use the profiler the whole session…. OK- Session is not loaded at that stage and if use the Application_AcquireRequestState and a static variable it loads it many many times and the profiler does work sometimes, sometimes not and I do not know why?

The simple way I have now is.

protected void Application_BeginRequest(object sender, EventArgs e)
        {
            MiniProfiler profiler = null;

            if (Request.QueryString["p"] != null)
            {

                profiler = MiniProfiler.Start();

                using (profiler.Step("Application_BeginRequest"))
                {
                }
            }


        }

So that works ok but i have to add a query param on each request. Not good. I never used global.asax before so I am not 100% sure how it all works down there.

What is the best way I can set a variable for a pre defined time so the profiler will always load when I turn it on in a secret way?


Edit and solution to my problem

 protected void Application_BeginRequest(object sender, EventArgs e)
        {
            MiniProfiler profiler = null;
            if (Request.Cookies["profiler"] != null)
            {
                profiler = MiniProfiler.Start();

                using (profiler.Step("Application_BeginRequest"))
                {
                }
            }

        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T11:22:24+00:00Added an answer on June 18, 2026 at 11:22 am

    If you added MiniProfiler via the MiniProfiler.MVC3 package, then it adds a C# file for your convenience in configuring it: look in App_Start\MiniProfiler.cs, looking in particular at Init which has the code to decide whether to start profiling (request.IsLocal is the default)

    In your case, I would suggest checking for a cookie in the start condition, and checking your more complete “am I a developer, or just someone who heard about a special cookie” in the end condition; in particular, if you call MiniProfiler.Stop(false), then all the data is discarded. Your “turn it on in a secret way” and “pre defined time” are then all achieved cheaply via the cookie, with the “am I a developer” there to make sure that it can’t be abused just by setting a cookie.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web application that I am currently working on that uses a
I have a java web application that uses form based authentication. If a standard
I have a pretty simple ASP.NET Web Form that looks a bit like the
I have a simple web browser embedded in an application that allows a user
I have a simple web service that uses an oracle database. When I test
I have a simple web form that sends and email out via .NET C#.
I have a .Net Framework 4.5 Web Form application that was recently deployed to
I have a simple page in a PHP/MySQL web application that lets admin users
I have been asked to build a rather simple form processor application that interacts
I am learning Entity Framework 4. I have a simple ASP.NET (Web Form) application.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.