By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,740 Members | 844 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,740 IT Pros & Developers. It's quick & easy.

Is it a mistake to put passwords in an .asmx.cs file on the web server?

P: n/a
Hi,

I'm building a web service which connects to a database. I have
hardcoded the connection string in the web service source code (an
asmx.cs file).

Is this a mistake? Is there someplace else I should put the database
connection string or just the password?

BTW, is it a bad idea to leave .asmx.cs files on the web server? I
don't think they need to be there for the app to function. I wonder
why Visual Studio doesn't leave them on my local disk?

Thanks,
John
Nov 18 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
There is no need to put the .cs file up there, since everything is compiled.
It is recommended that you do not hard code passwords or connection strings,
since every time that changes, you have to recompile. It is much easier to
change a configuration file.

I don't know how you are copying the files over, but VS.NET probably thinks
you want the whole project up there if that is what you are copying.

You can just copy all the necessary files by hand, so only the minimal is
there.

"John" <jo********@hotmail.com> wrote in message
news:d8**************************@posting.google.c om...
Hi,

I'm building a web service which connects to a database. I have
hardcoded the connection string in the web service source code (an
asmx.cs file).

Is this a mistake? Is there someplace else I should put the database
connection string or just the password?

BTW, is it a bad idea to leave .asmx.cs files on the web server? I
don't think they need to be there for the app to function. I wonder
why Visual Studio doesn't leave them on my local disk?

Thanks,
John

Nov 18 '05 #2

P: n/a
Are you using "Copy Project"? If so, you should see the option to copy
"Only the files needed to run the application", which won't put source
files on the server.

HTH,

--
Scott
http://www.OdeToCode.com

On 21 Jun 2004 08:50:40 -0700, jo********@hotmail.com (John) wrote:
Hi,

I'm building a web service which connects to a database. I have
hardcoded the connection string in the web service source code (an
asmx.cs file).

Is this a mistake? Is there someplace else I should put the database
connection string or just the password?

BTW, is it a bad idea to leave .asmx.cs files on the web server? I
don't think they need to be there for the app to function. I wonder
why Visual Studio doesn't leave them on my local disk?

Thanks,
John


Nov 18 '05 #3

P: n/a
Thanks for your posting.

I started Visual Studio and told it I wanted to create a new web
service. It asked for the URL and I gave the URL to my site (hosted by
a hosting company).

Is there something I should do to tell VS to not upload the cs files?
I really like that when I press CONTROL-ALT-B the solution is built
and uploaded to the server for me to test.

I see that the solution is stored locally. I kind of like this because
I can take the .sln file home with me and all the code is on the
hosting server so as long as I delete my VSWebCache directory I can
work on the code from both places. Is this a bad thing to be doing?

John

Scott Allen <bitmask@[nospam].fred.net> wrote in message news:<9q********************************@4ax.com>. ..
Are you using "Copy Project"? If so, you should see the option to copy
"Only the files needed to run the application", which won't put source
files on the server.

HTH,

--
Scott
http://www.OdeToCode.com

On 21 Jun 2004 08:50:40 -0700, jo********@hotmail.com (John) wrote:
Hi,

I'm building a web service which connects to a database. I have
hardcoded the connection string in the web service source code (an
asmx.cs file).

Is this a mistake? Is there someplace else I should put the database
connection string or just the password?

BTW, is it a bad idea to leave .asmx.cs files on the web server? I
don't think they need to be there for the app to function. I wonder
why Visual Studio doesn't leave them on my local disk?

Thanks,
John

Nov 18 '05 #4

P: n/a
Thanks for your reply.

Where should I put the password and connection strings if not hardcoded?

Do you know how to tell VS to not put the whole project up on the server?

Thanks,
John

"Marina" <so*****@nospam.com> wrote in message news:<ez**************@TK2MSFTNGP12.phx.gbl>...
There is no need to put the .cs file up there, since everything is compiled.
It is recommended that you do not hard code passwords or connection strings,
since every time that changes, you have to recompile. It is much easier to
change a configuration file.

I don't know how you are copying the files over, but VS.NET probably thinks
you want the whole project up there if that is what you are copying.

You can just copy all the necessary files by hand, so only the minimal is
there.

"John" <jo********@hotmail.com> wrote in message
news:d8**************************@posting.google.c om...
Hi,

I'm building a web service which connects to a database. I have
hardcoded the connection string in the web service source code (an
asmx.cs file).

Is this a mistake? Is there someplace else I should put the database
connection string or just the password?

BTW, is it a bad idea to leave .asmx.cs files on the web server? I
don't think they need to be there for the app to function. I wonder
why Visual Studio doesn't leave them on my local disk?

Thanks,
John

Nov 18 '05 #5

P: n/a
Hi John:

When you create the web service in this fashion there there is no way
to keep the source code files off the server. There is nothing
inherently wrong or bad about this approach - it's whatever you feel
comfortable with.

I would be uncomfortable because I'm afraid I might put a bug into the
service and have it appear on the server before I have a chance to
test it. I would create the web application on my local machine. After
writing some code and doing some testing, then I'd upload it to the
hosting provider.

--s

On 21 Jun 2004 17:51:09 -0700, jo********@hotmail.com (John) wrote:
Thanks for your posting.

I started Visual Studio and told it I wanted to create a new web
service. It asked for the URL and I gave the URL to my site (hosted by
a hosting company).

Is there something I should do to tell VS to not upload the cs files?
I really like that when I press CONTROL-ALT-B the solution is built
and uploaded to the server for me to test.

I see that the solution is stored locally. I kind of like this because
I can take the .sln file home with me and all the code is on the
hosting server so as long as I delete my VSWebCache directory I can
work on the code from both places. Is this a bad thing to be doing?

John

Scott Allen <bitmask@[nospam].fred.net> wrote in message news:<9q********************************@4ax.com>. ..
Are you using "Copy Project"? If so, you should see the option to copy
"Only the files needed to run the application", which won't put source
files on the server.

HTH,

--
Scott
http://www.OdeToCode.com

On 21 Jun 2004 08:50:40 -0700, jo********@hotmail.com (John) wrote:
>Hi,
>
>I'm building a web service which connects to a database. I have
>hardcoded the connection string in the web service source code (an
>asmx.cs file).
>
>Is this a mistake? Is there someplace else I should put the database
>connection string or just the password?
>
>BTW, is it a bad idea to leave .asmx.cs files on the web server? I
>don't think they need to be there for the app to function. I wonder
>why Visual Studio doesn't leave them on my local disk?
>
>Thanks,
>John


--
Scott
http://www.OdeToCode.com
Nov 18 '05 #6

P: n/a
Is there a way to tell Visual Studio to not put .cs and other
non-necessary files on the server when creating/compiling a web
application?

Thanks,
John

Scott Allen <bitmask@[nospam].fred.net> wrote in message news:<8i********************************@4ax.com>. ..
Hi John:

When you create the web service in this fashion there there is no way
to keep the source code files off the server. There is nothing
inherently wrong or bad about this approach - it's whatever you feel
comfortable with.

I started Visual Studio and told it I wanted to create a new web
service. It asked for the URL and I gave the URL to my site (hosted by
a hosting company).

Is there something I should do to tell VS to not upload the cs files?
I really like that when I press CONTROL-ALT-B the solution is built
and uploaded to the server for me to test.

I see that the solution is stored locally. I kind of like this because
I can take the .sln file home with me and all the code is on the
hosting server so as long as I delete my VSWebCache directory I can
work on the code from both places. Is this a bad thing to be doing?

Nov 18 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.