ASP.NET File Paths

RajK

Guppy
Hi,

I'm relatively new to ASP.NET, and I am sure many of you have already
figured this out.

I am trying to create a file, called count.dat in my web folder.
The problem is I cannot get the path right.

If I try to create it using the path: "count.dat" I get an error saying
access to C:\winnt\system32\count.dat is denied!

I can create it using the path: "/count.dat" and it works like it is supposed
to but I have no clue where it got created and cannot find it!

If I use a path like: /username/domain/count.dat it tells me it
cannot find the path in the C: drive!

Any clue anyone can give me about this problem would be much appreciated.

Thanks!

Raj
 
WineIsGood said:
In ASPX in-line script, use "~/count.dat"
In VB code-behind, use Page.ResolveUrl("~/count.dat")

-Dave

Thanks Dave,

That gave me the idea of using the Page.MapPath("") method
to get the physical address of the current directory.

Raj
 
Would
Server.MapPath("name of file")
be of any help here. That is what I need to use to get my access databases to connect.

KJTFS
 
kjtfs said:
Would
Server.MapPath("name of file")
be of any help here. That is what I need to use to get my access databases to connect.

KJTFS

Yup, haven't tried it yet, but it seems all the MapPath() methods are derived
from a common Base class.

Raj
 
RajK said:
Yup, haven't tried it yet, but it seems all the MapPath() methods are derived
from a common Base class.

Raj

I am having a similiar issue...not with not knowing the path of a file to create...but acessing a file that's already created. I try to read an xml from an ASP.NET page, using the following code:

private DataSet CreateDataSource(){
XmlDataDocument mydata = new XmlDataDocument();
mydata.DataSet.ReadXml(Server.MapPath(XMLFilePath));
return mydata.DataSet;
}


The ReadXML File throws in the following error:

ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6) that is used if the application is not impersonating. If the application is impersonating via <identity impersonate="true"/>, the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.

I asked the admin to change the permissions for me...still waiting for a response.

Did anyone else have a similar problem..ever?
 
DeepakG said:
Did anyone else have a similar problem..ever?
Yep, sure. Me for example. What I did is asked support to give write permissions for ASP.NET (this is not same as ASP) to some folder, then put all files/databases I need to be writable in it. After that you can create a subfolders inside it, they will be writable as well.
So if you still didn't get a response, I suggest re-submitting your ticket, or writing directly to [email protected]. Sometimes there is some problem occure in HSPHERE, and support doens't get notifications on new tickets. That's why you may wait a long time.
 
StPatrick said:
Yep, sure. Me for example. What I did is asked support to give write permissions for ASP.NET (this is not same as ASP) to some folder, then put all files/databases I need to be writable in it. After that you can create a subfolders inside it, they will be writable as well.
So if you still didn't get a response, I suggest re-submitting your ticket, or writing directly to [email protected]. Sometimes there is some problem occure in HSPHERE, and support doens't get notifications on new tickets. That's why you may wait a long time.

I just e-mailed them again. Let's see what happens.

I actually used to host with a different hosting company and that had the functionality in their control panel to change permission for files/folders. I guess we should have some sort of control over permissions once webshell 4 is deployed on Jodohost. But even than, I would think it would be impossible to give permissions based on usernames. Oh well...can't wait for support to take care of this.
 
I believe support has replied to both of your emails granting necessary permission. Let us know if it does not work.
 
atulkumar said:
I believe support has replied to both of your emails granting necessary permission. Let us know if it does not work.

Oops! I guess the permissions were applied in time...I just happened to have a small bug in my code ;) Works great now.
 
Back
Top