Proper Location of Files

B

Bryan Masephol

I've been getting myself fimiliar with ASP.Net and C# and am trying to read
my database connection infomation from an xml preference file that is
located on the web server. I just built a simple web app and can execute
the test page I made with the hard coded db values and everything works
fine. When I swap in my code for reading from the xml preference file I get
an error saying the xml document that I'm reading with is null.

So I pulled out all the code to and made a test program to test my xml
reading code locally and it worked fine... so I'm thinking that its not
finding the xml file and then xml document is never built and is null.

So I thought I would write out a little test txt file from within my web
application to find out what directory the code was looking in for my xml
preference file.... but I am not able to find this file.

If I have my index.aspx file in the folder race...

/race/index.aspx

and I tell it to just

XmlTextReader reader = new XmlTextReader("DBConnection.xml");

and I have the file

/race/DBConnection.xml

in that location shouldn't it work?

Thanks for any input

Bryan
 
S

S. Justin Gengo

Bryan,

One thing to check is if the ASPNet user account has access to the file
location. If the ASPNet user account doesn't have access to the file then
you may experience this error.

Try wrapping the file access line in a Try/Catch to see if you can capture
the actual error. I'm betting that it's a permissions issue.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
 
B

Bryan Masephol

Thanks for the reply Justin

Problem is that I don't see an ASPNet user account on my web server (win
2003). Shouldn't one have been setup when I configured ASP.Net on the
server?

Thanks
Bryan
 
S

S. Justin Gengo

Bryan,

If your app runs the account has to be there.

In Computer Management - Local Users and Groups - Users folder

It is specifically:

Name: ASPNET

Full Name: ASP.NET Machine Account

Description: Account used for running the ASP.NET worker process
(aspnet_wp.exe)

If you don't see that account then I can't imagine how your app could be
running on the server.

That said, there are specific ways to set up a domain account which can be
used to run the ASP.NET worker process with. (We're doing that at the
company I work full time at. It's more secure.)

I would check to see if you aren't running a domain account. If so that
account would need to be given permissions to the file.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
 
B

Bryan Masephol

Thanks for all the help.

After messing around some more with accounts I was able to get it to work.
I didn't have read access on the directory that I was trying to read from
for the Account that was running the ASP.NET worker process. Thanks for you
help!

Bryan
 

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,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top