Where does web.config go?

K

K Viltersten

I've changed the declaration of the
connection string in my application from

String conStr = "the string";

to an external one, behaving as a property
of my class (supposedly, a nicer approach,
i've been told).

private string _ConStr;
public string ConStr {
get {
if (String.IsNullOrEmpty(_ConStr))
_ConStr = GetConnectionString();
return _ConStr; }
set { } }

After that, i've designed the method for
obtaining the connection string as follows.

private string GetConnectionString() {
ConnectionStringsSection css
= ConfigurationManager.GetSection
("connectionStrings") as
ConnectionStringsSection;
return
css.ConnectionStrings["MyConStr"]
.ConnectionString; }

In the web.config file i have these lines.

<connectionStrings>
<add name="MyConStr"
connectionString="the string" />
</connectionStrings>

Now, my question is twofold. First of all,
i'd like to know where i should put in
the web.config file when i install my
software on the computer of the intended
user. Secondly, i wonder if i've missed
something important in my approach.
 
K

K Viltersten

I've changed the declaration of the

Do i miss something? In my client it looks
like an empty message (well, not empty but
only consisting of the original question).

Am i missing a point?
 
K

K Viltersten

First of all, I'd like to know where I shouldput the web.config file when
Can you clarify please? Is this a web application?

Yes, it is. I consists of an two APSX-files
with corresponsing CS-files.
If so, generally speaking, you would not install it on a user's computer
but on a web server from where the user(s) can access it via a web
browser...

Right, my bad. By "the user" i ment the
server, of course. If i put the Index.ASPX
at a certain location, where it's found and
can be accessed, where should i put
web.config?

I'm also guessing that if the connection
string contained

Data Source=MyMachine\SQLEXPRESS;

it needs to be changed to

Data Source=TheServer\SQLEXPRESS;

right?
 
K

K Viltersten

I'm also guessing that if the connection string contained
You need to change the connection string to the location of the database
from the point of view of the webserver...

Got it. Thanks a lot. I'll be back crying
if i don't get it to work. :)
 

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,995
Messages
2,570,230
Members
46,816
Latest member
SapanaCarpetStudio

Latest Threads

Top