Connection String

I

IntraRELY

I am building a standard ecomm shopping cart site. There are both public and
manage pages. I usually store the connection string w/in the code behind
page. I am not sure the best method is. I will be transferring the pages to
the live host after development and think that storing in a central location
maybe of benefit, so I do not have to make changes on 20 pages. However, I
only have to do one and could simply use a find and replace very easily. I
am looking for both a secure and easy solution.


TIA,

Steve
 
S

Steven Cheng[MSFT]

Thanks for Patrick and Rakesh's good suggestions.

Hi Steve,

Since you mentioned that your web application will be transfered to a live
host , so in addition to use web.config, you can also consider building a
separate assembly (dll) which contains a class and the class only used to
store some application level constants( use const member variables). Then,
when you develop the web app, you can reference the dll in VS.NET IDE.
When you deploying your app, you can simply put that dll together with your
web app's main assembly in the bin folder and when you want to modify some
of the constant values, just rebuild the separate dll and update it in the
bin folder.
Hope also helps.

Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
S

Steve W

I think I will put it in the web.config and encrypt it. I am interested
in this other solution, however, I understand the theory, but do not
know how to create a class by itself. Can you point me to the right
direction?

TIA,

Steve
 
S

Steven Cheng[MSFT]

Hi Steve,

To create a separate assembly(dll) with a single class. You can just use
VS.NET to create a new Class Library project , then, in that project,
define your class which contains only some constant values. For example:

using .....

namespace YOUR_WEB_APP_NAMESPACE
{
public class AppConstants
{
public const string connectionstring = "....";

...........other constant values

}

}

Build the project and you'll get a single assembly(dll). And reference this
dll in your main asp.net project. Also, if you don't want to use VS.NET,
you can also use notepad to create .cs file and define the class in it. And
build the assembly in commandline via the
csc /t:library classfile.cs

to create the asssembly. If there is anything else unclear , please feel
free to post here. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 

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

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,157
Latest member
MercedesE4
Top