473,322 Members | 1,501 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Best way to do local testing?

I'm making a web application on my local server which will then be rolled
out onto our live site. My problem is that i tend to have to comment out
and make a few new hard-coded lines in my files to edit changes locally and
then i have to reverse this process to make any changes live. See below
// local myLink.NavigateUrl = "http://localhost/TestSite/Printout.aspx";
myLink.NavigateUrl = http://www.mysite.com/Printout.aspx;

I'm thinking of making a variable in my web.config file to check whether i'm
running the application locally or not. So the following code below will
work:

bool isTest =
Convert.ToBoolean(ConfigurationSettings.AppSetting s["TestSite"]);

if (isTest)
myLink.NavigateUrl = "http://localhost/TestSite/Printout.aspx";
else
myLink.NavigateUrl = http://www.mysite.com/Printout.aspx;

Is there a better method of doing this? Maybe with the Debug class or
something that runs in debugging mode?

Thanks, Janaka
Nov 18 '05 #1
5 1720
Hi Janaka,

Your idea of moving hardcoded values into web.config is good.

But best practises you should never hardcode any values.

if at all you need to hardcode it should be easily configurable as you are
doing in web.config.

Just go ahead. You are on right track.

Thanks
Raghavendra
"Janaka" <ja****@magicalia.com> wrote in message
news:uM**************@TK2MSFTNGP15.phx.gbl...
I'm making a web application on my local server which will then be rolled
out onto our live site. My problem is that i tend to have to comment out
and make a few new hard-coded lines in my files to edit changes locally and then i have to reverse this process to make any changes live. See below
// local myLink.NavigateUrl = "http://localhost/TestSite/Printout.aspx";
myLink.NavigateUrl = http://www.mysite.com/Printout.aspx;

I'm thinking of making a variable in my web.config file to check whether i'm running the application locally or not. So the following code below will
work:

bool isTest =
Convert.ToBoolean(ConfigurationSettings.AppSetting s["TestSite"]);

if (isTest)
myLink.NavigateUrl = "http://localhost/TestSite/Printout.aspx";
else
myLink.NavigateUrl = http://www.mysite.com/Printout.aspx;

Is there a better method of doing this? Maybe with the Debug class or
something that runs in debugging mode?

Thanks, Janaka

Nov 18 '05 #2
You can use preprocessor statements to do this:

#if DEBUG
myLink.NavigateUrl = "http://localhost/TestSite/Printout.aspx"
#else
myLink.NavigateUrl = http://www.mysite.com/Printout.aspx;
#endif

The good thing about using preprocessor statements is that the debug code
isn't even compiled into the class when you compile it in Release mode. The
preprocessor statement indicates which line of code should be compiled,
depending upon whether you are compiling in Debug or Release mode.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Janaka" <ja****@magicalia.com> wrote in message
news:uM**************@TK2MSFTNGP15.phx.gbl...
I'm making a web application on my local server which will then be rolled
out onto our live site. My problem is that i tend to have to comment out
and make a few new hard-coded lines in my files to edit changes locally and then i have to reverse this process to make any changes live. See below
// local myLink.NavigateUrl = "http://localhost/TestSite/Printout.aspx";
myLink.NavigateUrl = http://www.mysite.com/Printout.aspx;

I'm thinking of making a variable in my web.config file to check whether i'm running the application locally or not. So the following code below will
work:

bool isTest =
Convert.ToBoolean(ConfigurationSettings.AppSetting s["TestSite"]);

if (isTest)
myLink.NavigateUrl = "http://localhost/TestSite/Printout.aspx";
else
myLink.NavigateUrl = http://www.mysite.com/Printout.aspx;

Is there a better method of doing this? Maybe with the Debug class or
something that runs in debugging mode?

Thanks, Janaka

Nov 18 '05 #3
Thanks Kevin that's what I was looking for

"Kevin Spencer" <ks******@takempis.com> wrote in message
news:uU**************@TK2MSFTNGP15.phx.gbl...
You can use preprocessor statements to do this:

#if DEBUG
myLink.NavigateUrl = "http://localhost/TestSite/Printout.aspx"
#else
myLink.NavigateUrl = http://www.mysite.com/Printout.aspx;
#endif

The good thing about using preprocessor statements is that the debug code
isn't even compiled into the class when you compile it in Release mode. The preprocessor statement indicates which line of code should be compiled,
depending upon whether you are compiling in Debug or Release mode.

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Janaka" <ja****@magicalia.com> wrote in message
news:uM**************@TK2MSFTNGP15.phx.gbl...
I'm making a web application on my local server which will then be rolled out onto our live site. My problem is that i tend to have to comment out and make a few new hard-coded lines in my files to edit changes locally

and
then i have to reverse this process to make any changes live. See below
// local myLink.NavigateUrl = "http://localhost/TestSite/Printout.aspx"; myLink.NavigateUrl = http://www.mysite.com/Printout.aspx;

I'm thinking of making a variable in my web.config file to check whether

i'm
running the application locally or not. So the following code below will work:

bool isTest =
Convert.ToBoolean(ConfigurationSettings.AppSetting s["TestSite"]);

if (isTest)
myLink.NavigateUrl = "http://localhost/TestSite/Printout.aspx";
else
myLink.NavigateUrl = http://www.mysite.com/Printout.aspx;

Is there a better method of doing this? Maybe with the Debug class or
something that runs in debugging mode?

Thanks, Janaka


Nov 18 '05 #4

"Janaka" <ja****@magicalia.com> wrote in message news:uM**************@TK2MSFTNGP15.phx.gbl...
I'm making a web application on my local server which will then be rolled
out onto our live site. My problem is that i tend to have to comment out
and make a few new hard-coded lines in my files to edit changes locally and
then i have to reverse this process to make any changes live. See below
// local myLink.NavigateUrl = "http://localhost/TestSite/Printout.aspx";
myLink.NavigateUrl = http://www.mysite.com/Printout.aspx;

I'm thinking of making a variable in my web.config file to check whether i'm
running the application locally or not. So the following code below will
work:

bool isTest =
Convert.ToBoolean(ConfigurationSettings.AppSetting s["TestSite"]);

if (isTest)
myLink.NavigateUrl = "http://localhost/TestSite/Printout.aspx";
else
myLink.NavigateUrl = http://www.mysite.com/Printout.aspx;

Is there a better method of doing this? Maybe with the Debug class or
something that runs in debugging mode?

Thanks, Janaka


Specifically for URL's you could use Request.ApplicationPath to get the start
for your local url.
A second approach is to use the "~" in your URL's, which expands to the
applicationpath, *IF* that URL is processed by asp.net.
You then use myLink.NavigateURL = "~/PrintOut.aspx", which will lead to
the correct file.

Hans Kesting
Nov 18 '05 #5
I use HttpUrlBuilder from Rainbow portal (www.rainbowportal.net):
public class HttpUrlBuilder

{

/// <summary>

/// Builds the url for get to current portal home page

/// containing the application path, portal alias, tab ID, and language.

/// </summary>

public static string BuildUrl()

{

return(BuildUrl("~/" + HttpUrlBuilder.DefaultPage, 0, 0, null, string.Empty,
string.Empty,string.Empty));

}

/// <summary>

/// Builds the url for get to current portal home page

/// containing the application path, portal alias, tab ID, and language.

/// </summary>

/// <param name="targetPage">Linked page</param>

public static string BuildUrl(string targetPage)

{

return(BuildUrl(targetPage, 0, 0, null, string.Empty, string.Empty,
string.Empty));

}

...... (many lines of code)

It load site url from web config and create urls. In aspx files I use
HttpUrlBuild too:

<a href='<%# Beer.HttpUrlBuilder.BuildUrl("Default.aspx")%>'><i mg src='<%#
Beer.HttpUrlBuilder.BuildUrl("img/logo.gif")%>' height="92" width="157"
alt="îÁ ÇÌÁ×ÎÕÀ" hspace="20"></a>

"Janaka" <ja****@magicalia.com> ÓÏÏÂÝÉÌ/ÓÏÏÂÝÉÌÁ × ÎÏ×ÏÓÔÑÈ ÓÌÅÄÕÀÝÅÅ:
news:uM**************@TK2MSFTNGP15.phx.gbl...
I'm making a web application on my local server which will then be rolled
out onto our live site. My problem is that i tend to have to comment out
and make a few new hard-coded lines in my files to edit changes locally and then i have to reverse this process to make any changes live. See below
// local myLink.NavigateUrl = "http://localhost/TestSite/Printout.aspx";
myLink.NavigateUrl = http://www.mysite.com/Printout.aspx;

I'm thinking of making a variable in my web.config file to check whether i'm running the application locally or not. So the following code below will
work:

bool isTest =
Convert.ToBoolean(ConfigurationSettings.AppSetting s["TestSite"]);

if (isTest)
myLink.NavigateUrl = "http://localhost/TestSite/Printout.aspx";
else
myLink.NavigateUrl = http://www.mysite.com/Printout.aspx;

Is there a better method of doing this? Maybe with the Debug class or
something that runs in debugging mode?

Thanks, Janaka

Nov 18 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Dave Smithz | last post by:
Hi There, I have taken over someone else's PHP code and am quite new to PHP. I made some changes and have implemented them to a live environment fine so far. However, I now want to setup a...
1
by: enrique | last post by:
Hello everyone, I'm looking for a "directory path" solution that will allows me to test my app locally and then test on remote web server without having to update my web.config file each time I...
136
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their...
0
by: John Hoge | last post by:
I'm testing VWD, which has some great features over VS.NET2003, but there is one feature that it seems to lack: I want to do my development and testing on a local testing server. Dreamweaver...
0
by: Ken Allen | last post by:
The MSDN documentation on remote debugging is a bit sparse, to say the least, and there is almost no information available on the 'best' way to configure this. I should note that my development...
3
by: RLN | last post by:
(New to SQL Server Installs) I installed SQL Server 2005 Developer Edition on a WinXP-SP2 workstation and can see some enterprise databases on the network just fine. My problem is I cannot...
5
by: andy | last post by:
I currently use Eclipse for creating the PHP application, which is great for editing but quite slow when using FTP. But when im testing i like to use CuteFTP Pro for quicky editing and seeing the...
2
by: Nikhil | last post by:
I am using the MySQLdb python module. I have a table named 'testing' with few columns, under the 'test' database, what is hosted on a remote mysql server. I want to run the following query to...
10
by: Brendan Miller | last post by:
What would heavy python unit testers say is the best framework? I've seen a few mentions that maybe the built in unittest framework isn't that great. I've heard a couple of good things about...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.