Visual Studio 2005

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is there a way to know if a project runs inside Visual Studio. I have a file
based web site. The project name is added to the url, which messed up my menu.
 
Hi Arne,

Have you tried checking?

if (Reuqest.Url.Port!=80) {
//this means you are debugging in VS 2005
}

Another way to consider for debugging is the use of conditional compilation
directives
http://msdn.microsoft.com/library/d...y/en-us/csspec/html/vclrfcsharpspec_2_5_4.asp

e.g. add at the top of the codebehind file:
#define Debug

Then in the body where you want to remove the project name from the URL:

string myURL = Request.Url.LocalPath;
#if Debug
myURL= Request.Url.LocalPath.Replace(Request.Url.Segments[1],"");
#endif

Then when you deploy to production you just need to comment out the
directive at the top of the page.
 
Still a couple of more elegant methods for detecting whether an application
is running in debug mode or not:

1)
http://msdn2.microsoft.com/en-us/library/system.diagnostics.debugger.isattached.aspx

2) I could have simply written
#if (DEBUG)
{ // process debugging-specific commands}
#endif


Phillip Williams said:
Hi Arne,

Have you tried checking?

if (Reuqest.Url.Port!=80) {
//this means you are debugging in VS 2005
}

Another way to consider for debugging is the use of conditional compilation
directives
http://msdn.microsoft.com/library/d...y/en-us/csspec/html/vclrfcsharpspec_2_5_4.asp

e.g. add at the top of the codebehind file:
#define Debug

Then in the body where you want to remove the project name from the URL:

string myURL = Request.Url.LocalPath;
#if Debug
myURL= Request.Url.LocalPath.Replace(Request.Url.Segments[1],"");
#endif

Then when you deploy to production you just need to comment out the
directive at the top of the page.
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com


Arne said:
Is there a way to know if a project runs inside Visual Studio. I have a file
based web site. The project name is added to the url, which messed up my menu.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top