Click here to Skip to main content
15,879,535 members
Articles / .NET
Tip/Trick

Run/Debug with New Browser Session in Visual Studio

Rate me:
Please Sign up or sign in to vote.
5.00/5 (3 votes)
27 Aug 2013CPOL1 min read 32.3K   3   7
A solution for starting with a new browser session each time you run/debug a VS web project

Introduction

I've been doing this trick for a while now and thought it was worth sharing. The problem is when you rely on cookie values in a web-app, in order to reset these values, you need to remove the cookies manually (or in code) on app start. Not ideal. The solution to this minor annoyance is to set up specific browser sessions that use the "PRIVATE BROWSING" command line parameters of browsers. What happens is when you start a private browsing session, it does not use any cached cookies or other settings so you can test with a clean slate - handy.

Setting It Up

In Visual Studio, select the drop-down arrow to the right of the browser choice window:

Image 1

Now select "browse with"...

Image 2

In the dialog that pops up, select "add", and use the "..." button to locate your browser. In Arguments, enter the "in private" command line argument your chosen browser takes.

Image 3

Image 4

For chrome, use "-incognito", for Internet Explorer, use "-private". The documented "-private" for Firefox does not seem to work.

Your new run with browser menu should now show the new options:

Image 5

When you run/debug, you get your new shiney cookie free window!

Image 6

Image 7

Enjoy your low-fat "cookie cache free" testing!

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Chief Technology Officer SocialVoice.AI
Ireland Ireland
Allen is CTO of SocialVoice (https://www.socialvoice.ai), where his company analyses video data at scale and gives Global Brands Knowledge, Insights and Actions never seen before! Allen is a chartered engineer, a Fellow of the British Computing Society, a Microsoft mvp and Regional Director, and C-Sharp Corner Community Adviser and MVP. His core technology interests are BigData, IoT and Machine Learning.

When not chained to his desk he can be found fixing broken things, playing music very badly or trying to shape things out of wood. He currently completing a PhD in AI and is also a ball throwing slave for his dogs.

Comments and Discussions

 
QuestionRun/Debug with new browser session in Visual Studio Pin
MarcelHorsthuis9-Feb-15 21:26
MarcelHorsthuis9-Feb-15 21:26 
AnswerRe: Run/Debug with new browser session in Visual Studio Pin
DataBytzAI9-Feb-15 22:41
professionalDataBytzAI9-Feb-15 22:41 
QuestionCan't get it to work Pin
Silvabolt13-May-14 6:19
Silvabolt13-May-14 6:19 
AnswerRe: Can't get it to work Pin
DataBytzAI13-May-14 6:36
professionalDataBytzAI13-May-14 6:36 
GeneralRe: Can't get it to work Pin
Silvabolt13-May-14 8:48
Silvabolt13-May-14 8:48 
GeneralRe: Can't get it to work Pin
Silvabolt13-May-14 9:49
Silvabolt13-May-14 9:49 
GeneralRe: Can't get it to work Pin
DataBytzAI13-May-14 9:50
professionalDataBytzAI13-May-14 9:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.