473,499 Members | 1,551 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Where does web.config go?

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.

--
Regards
Konrad Viltersten
----------------------------------------
May all spammers die an agonizing death;
have no burial places; their souls be
chased by demons in Gehenna from one room
to another for all eternity and beyond.
Oct 2 '08 #1
7 2165
"K Viltersten" <tm**@viltersten.comwrote in message
news:6k************@mid.individual.net...
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.

--
Regards
Konrad Viltersten
----------------------------------------
May all spammers die an agonizing death;
have no burial places; their souls be
chased by demons in Gehenna from one room
to another for all eternity and beyond.


--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Oct 2 '08 #2
"K Viltersten" <tm**@viltersten.comwrote in message
news:6k************@mid.individual.net...
First of all, I'd like to know where I should put the web.config file when
i install my software on the computer of the intended user.
Can you clarify please? Is this a web application?

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...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Oct 2 '08 #3
>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).
<snip>


--
Mark Rae
ASP.NET MVP
http://www.markrae.net

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?

--
Regards
Konrad Viltersten
----------------------------------------
May all spammers die an agonizing death;
have no burial places; their souls be
chased by demons in Gehenna from one room
to another for all eternity and beyond.
Oct 2 '08 #4
>First of all, I'd like to know where I shouldput the web.config file when
>i install my software on the computer of the intended user.

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?

--
Regards
Konrad Viltersten
----------------------------------------
May all spammers die an agonizing death;
have no burial places; their souls be
chased by demons in Gehenna from one room
to another for all eternity and beyond.
Oct 2 '08 #5
"K Viltersten" <tm**@viltersten.comwrote in message
news:6k************@mid.individual.net...
Do i miss something? In my client it looks
like an empty message (well, not empty but
only consisting of the original question).
My fault - hit the button too soon - see second message...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Oct 2 '08 #6
"K Viltersten" <tm**@viltersten.comwrote in message
news:6k************@mid.individual.net...
>>First of all, I'd like to know where I shouldput the web.config file
when i install my software on the computer of the intended user.

Can you clarify please? Is this a web application?

Yes, it is. It consists of an two APSX files with corresponsing CS files.
OK.
>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 meant 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?
In the root of the virtual directory. I'm assuming that you know that you
can't just copy aspx files to a file server - ASP.NET needs a webserver e.g
IIS - so you will need to create a virtual directory through the IIS MMC
snap-in in the usual way...
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?
You need to change the connection string to the location of the database
from the point of view of the webserver...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Oct 2 '08 #7
>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?

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. :)

--
Regards
Konrad Viltersten
----------------------------------------
May all spammers die an agonizing death;
have no burial places; their souls be
chased by demons in Gehenna from one room
to another for all eternity and beyond.
Oct 2 '08 #8

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

Similar topics

3
6543
by: Geoff Pennington | last post by:
It is really pathetic that I don't know this, but here it is. I have been writing ASP.Net apps for a while, and all configuration information, such as the database connection string, goes in a text...
3
1896
by: suzy | last post by:
hello, how do i check from my c# class if it is being called from a asp.net application or a windows application? i have some code that reads from the web.config file for webapps, but i want...
2
2268
by: Chris Dunaway | last post by:
I have a web service that references a data class library which performs SQL Server access. Since the web service is also a class library, there is no App.Config, only Web.config. Is Web.Config...
6
2022
by: ad | last post by:
We usually store the connection string of Web Applicaiton in Web.Config. Now I want to develop WinForm Application. Where is the better place to store the conneciton string?
3
3798
by: Richard Lewis Haggard | last post by:
I have a test application that is calling an assembly that reads some strings out of a config file. Normally, this assembly supports a web application and the information can be read just fine....
10
6799
by: Mike9900 | last post by:
Hello, I would like to store application expiration date in a file and store that file in a secure place, so the application can access the file for all the users on that computer. ...
0
1316
by: SuperJason | last post by:
We have a web application that uses 2 different virtual directories. - The first is an ASP.NET application that has web services that can be used to authenticate various clients. - The second is...
4
4362
by: siggi | last post by:
Hi all, newbie question: I'd like to try speech synthesis with PythonWin 2.5. Problem ****** according to several instructions, such as found on...
2
3069
by: Jerry Spence1 | last post by:
I am getting a protocol violation error from an IP product and after some searching I found the following fix: <?xml version="1.0" encoding="utf-8"?> <configuration> <appSettings> <!-- User...
4
2019
by: Rob | last post by:
The app.config in VB 2005 appears to be riddled with bugs.... From solution explorer I right click on the Project | Properties... then I use the grid to add the app settings... AND they are saved...
0
7007
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7220
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6893
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5468
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4599
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3098
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3090
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
664
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
295
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.