HTTP Handler to create, write files & account privileges

G

Guest

Hi,

I need to use an HTTPHandler to create and write files. I wanted to create
the file in the directory that has this handler, and other handlers. For me,
this directory is: c:\Inetpub\wwwroot\HttpHandlers. I get an error: "Access
to the path "C:\Inetpub\wwwroot\HTTPHandlers\bidhero.ccn" is denied."

I can have the code write files to other locations just fine. I'm using
ASP.net v.1.1 on Windows XP, and Windows 2003.

1. Which would be the best place to create and write this file to? This is
not a temporary file. Once created, it will be there for the length of the
application.

2. I've read several posts regarding this error, and they talk of account
privileges. How do I know which account is running this program, and how do
I change account privileges? How safe is it to change privileges to allow a
process to write?

Thanks.
-Shefali
 
M

Matt Berther

Hello shefali,

If the HttpHandler is writing out a file strictly for the purpose of allowing
a client to later make a request for it, why not just serve the file right
out of the HttpHandler? I do this all over the place for images that are
stored in a database.

If you're not using it for this purpose, why is the handler creating/writing
files?
 
G

Guest

Matt,

Thanks for your response.

What I have is two http handlers, one that receives data, saves this data,
data must stay persistent, and another handler that receives requests for
this data, and writes a file out as the response. Both have to handle
multiple requests at the same time.

So, how would what you propose work? Would I have a string or a property in
the class that I would write data to, and it would be stored in memory? Like
I said, the data needs to persist for the lifetime of the web application
(httphandler). What happens if the server reboots?

So, back to, if the only way to do this is to write a file, which physical
location should I write the file to?

Thank a ton.
-Shefali
 
M

Matt Berther

Hello shefali,

Fair enough... I presume that you've checked that the ASPNET account has
the appropriate NTFS permissions to actually write to that location?
 
R

Richard Blewett [DevelopMentor]

Also remember that for Win2003 by default the "Network Service" account will need write access to that location as the worker process doesn't run under the ASPNET account

Regards

Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk

Hello shefali,

Fair enough... I presume that you've checked that the ASPNET account has
the appropriate NTFS permissions to actually write to that location?
 
M

Matt Berther

Hello Richard Blewett [DevelopMentor],

Of course... Thanks for mentioning that...
 
G

Guest

Matt, Richard,

Thank you for your inputs.

Like I said, I have several web apps. If I change the ASPNET account
privilege to 'administrator', that would give all the webapps on the system
full control. Instead, would it not be better, if I don't change the account
privilege for the ASPNET account (leave it to its current 'limited' setting),
and write the files 'systemroot/temp'? Reading the .net Framework developers
Guide, section 'ASP.NET Required Access Control Lists (ACLs)', it seems that
'systemroot/temp' has access type 'Read/write/delete' and this location is
used to support web services. What do you think?

Thanks again.
-Shefali

Matt Berther said:
Hello Richard Blewett [DevelopMentor],

Of course... Thanks for mentioning that...
 
M

Matt Berther

Hello shefali,

I wasnt suggesting you set the priviledge to 'administrator'. I suggested
that you set the permissions on the folder you want to write to to allow
the ASPNET account.

--
Matt Berther
http://www.mattberther.com
Matt, Richard,

Thank you for your inputs.

Like I said, I have several web apps. If I change the ASPNET account
privilege to 'administrator', that would give all the webapps on the
system full control. Instead, would it not be better, if I don't
change the account privilege for the ASPNET account (leave it to its
current 'limited' setting), and write the files 'systemroot/temp'?
Reading the .net Framework developers Guide, section 'ASP.NET Required
Access Control Lists (ACLs)', it seems that 'systemroot/temp' has
access type 'Read/write/delete' and this location is used to support
web services. What do you think?

Thanks again.
-Shefali
Matt Berther said:
Hello Richard Blewett [DevelopMentor],

Of course... Thanks for mentioning that...

--
Matt Berther
http://www.mattberther.com
Also remember that for Win2003 by default the "Network Service"
account will need write access to that location as the worker
process doesn't run under the ASPNET account

Regards

Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk
Hello shefali,
Fair enough... I presume that you've checked that the ASPNET account
has
the appropriate NTFS permissions to actually write to that location?
 
G

Guest

Thank you very much. I did just this, and 'am happy with the solution.
Thanks a ton. -Shefali

Matt Berther said:
Hello shefali,

I wasnt suggesting you set the priviledge to 'administrator'. I suggested
that you set the permissions on the folder you want to write to to allow
the ASPNET account.

--
Matt Berther
http://www.mattberther.com
Matt, Richard,

Thank you for your inputs.

Like I said, I have several web apps. If I change the ASPNET account
privilege to 'administrator', that would give all the webapps on the
system full control. Instead, would it not be better, if I don't
change the account privilege for the ASPNET account (leave it to its
current 'limited' setting), and write the files 'systemroot/temp'?
Reading the .net Framework developers Guide, section 'ASP.NET Required
Access Control Lists (ACLs)', it seems that 'systemroot/temp' has
access type 'Read/write/delete' and this location is used to support
web services. What do you think?

Thanks again.
-Shefali
Matt Berther said:
Hello Richard Blewett [DevelopMentor],

Of course... Thanks for mentioning that...

--
Matt Berther
http://www.mattberther.com
Also remember that for Win2003 by default the "Network Service"
account will need write access to that location as the worker
process doesn't run under the ASPNET account

Regards

Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk
Hello shefali,
Fair enough... I presume that you've checked that the ASPNET account
has
the appropriate NTFS permissions to actually write to that location?
 

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

Top