January 4, 2018

Incognito Debugging With Any Browser in Visual Studio

Disclaimer: I imported this post from WordPress to Jekyll on 9/2/23. Forgive the misformatting until I get a chance to clean it up.

Clearing the Cruft

When I develop web applications in Visual Studio, I often need to resolve issues that are dependent on the state of the cache or cookies. By default, debugging in a browser from Visual Studio opens a new browser window but does not purge any preexisting cache or cookies.

Private/Incognito Browsing: Always Fresh

I like to configure Visual Studio to launch browser debug sessions in incognito/private browsing mode. Every debugging session is then fresh as if a user was visiting my application for the first time.

[![Visual Studio Debug Target Menu](/assets/img/vsDebugTargetMenu_collinmbarrett.jpg)](/assets/img/vsDebugTargetMenu_collinmbarrett.jpg)
Visual Studio Debug Target Menu

To configure browsers to debug in this mode:

  1. Click the Debug Target control’s right-side chevron to view the list of installed browsers.
  2. Click “Browse With…”.
  3. Click “Add…”.
  4. Configure the new target browser using the private/incognito command line argument. See the examples below.

Sample Browser Configurations

Chrome

Program:
`"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"`
Arguments:
`--incognito`
Friendly Name:
`Google Chrome - Incognito`

[Internet

Explorer](https://support.microsoft.com/en-us/windows/internet-explorer-downloads-d49e1f0d-571c-9a7b-d97e-be248806ca70)

Program:
`"C:\Program Files (x86)\Internet Explorer\iexplore.exe"`
Arguments:
`-private`
Friendly Name:
`Internet Explorer - InPrivate`

Firefox

Program:
`"C:\Program Files\Mozilla Firefox\firefox.exe"`
Arguments:
`-private`
Friendly Name:
`Firefox - Private`

Firefox Developer Edition

Program:
`"C:\Program Files\Firefox Developer Edition\firefox.exe"`
Arguments:
`-private`
Friendly Name:
`FirefoxDeveloperEdition - Private`

Edge

Not yet supported.

Opera

Program:
`"C:\Program Files\Opera\launcher.exe"`
Arguments:
`--private`
Friendly Name:
`Opera Internet Browser - Private`
[![Visual Studio Private/Incognito Debug Targets](/assets/img/vsDebugTargets_collinmbarrett-300x293.jpg)](/assets/img/vsDebugTargets_collinmbarrett.jpg)
Visual Studio Private/Incognito Debug Targets

via Scott Hanselman