Monday, October 19, 2009

How to debug the selected page inside selected project all the time?

As you might already know http://connect.microsoft.com is a way to open bugs/request suggestions on various Microsoft products… One of the repeated suggestion I see for Web Development within Visual Studio is the ability to hit F5 on any .aspx page within a solution and have it be treated as the “Start up page”…

It is pretty common to set a fixed page as a start up page within a Web Project…You could do that simply by right clicking the page of your choice and setting “Set as Start Page” as shown below:

Set As Start Page

The above will fix your start page to be “Default.aspx” and no matter what you select within the project, Default.aspx will start when you hit F5…

You can make the active selected page as your start up page by going to the Project –> Properties –> Web  and choosing the “Current Page” as your “Start Action”

Current Page Start Action

There is a similar option for Web Site Projects too, although the interesting ask comes up when you have more than one web project in your solution and you want to debug current page from the project you have currently selected…

Most people right click on their project and click “Set as StartUp Project” every time they want to change the project they are debugging  (as shown below):

Set as StartUp Project

Although there is a well kept secret in Visual Studio, which is worth noting…  You can actually right click on your “Solution File” and click “Set Start up  projects…”

Set StartUp Projects...

This will bring up the below dialog:

StartUp Projects

In this dialog you just need to select the radio button which says “Current Selection” and this will automatically make the project you are in as the start up project…

Effectively by choosing “Current Selection” for the Start Up Project and the “Current Page” for Start Action,  you can now very easily debug the project + web page of your choice simply hitting F5…

-Vishal

 

5 comments:

Dave said...

"One of the repeated suggestion I see for Web Development within Visual Studio is the ability to hit F5 on any .aspx page within a solution and have it be treated as the “Start up page”"

How about alt+F5 to have the current page be treated as the start up page, that would be useful!

savitha said...

Vishal,
I have some 15 web pages in my project. one of the page is StartUpPage.aspx, and want this to be my start page. I have also login.aspx page. When ever I run my project, it always shows login.aspx as start page. I have done the settings as you explain in this blog. When I go to Website->Start Options->Specify page ->"StartUpPage.aspx", even then I get login page as start page when I run my project. I want StartUpPage.aspx as start page, and I have hyper link in this page "login", when click on this hyperlink, that will take to login.aspx

I am using visual web developer 2008 express edition. What could be the problem in this case. I appreciate your help

radhe said...

Thanks Vishaal

Natalie said...

It is really an appreciable post. . Debugging is important part of web development and designing. The main thing in this post is that this is explained with the help of pictures. web development company

Anonymous said...

Sometimes, I think I'd really benefit from seeing an explanation of why and how this error arises in the first place. Saying something like "because you haven't specified a page to debug" isn't what I'm looking for. My problem is that things *were* working, and now they're not, and the only message I receive is "You need to specify a page to debug blah blah blah." What I so need to know is what happened that made things *quit* working, not just a way to reset things. Thanks.