Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / December 2004

Tip: Looking for answers? Try searching our database.

HTTP Handler to create, write files & account privileges

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
shefali - 02 Dec 2004 00:05 GMT
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
Matt Berther - 02 Dec 2004 06:07 GMT
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?

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

> Hi,
>
[quoted text clipped - 18 lines]
> Thanks.
> -Shefali
shefali - 03 Dec 2004 00:05 GMT
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

> Hello shefali,
>
[quoted text clipped - 32 lines]
> > Thanks.
> > -Shefali
Matt Berther - 03 Dec 2004 07:35 GMT
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?

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

> Matt,
>
[quoted text clipped - 52 lines]
>>> Thanks.
>>> -Shefali
Richard Blewett [DevelopMentor] - 03 Dec 2004 08:15 GMT
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?

--
Matt Berther
http://www.mattberther.com
Matt Berther - 03 Dec 2004 15:08 GMT
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
[quoted text clipped - 13 lines]
> Matt Berther
> http://www.mattberther.com
shefali - 03 Dec 2004 20:09 GMT
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

> Hello Richard Blewett [DevelopMentor],
>
[quoted text clipped - 21 lines]
> > Matt Berther
> > http://www.mattberther.com
Matt Berther - 04 Dec 2004 21:07 GMT
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,
>
[quoted text clipped - 36 lines]
>>> Matt Berther
>>> http://www.mattberther.com
shefali - 06 Dec 2004 18:41 GMT
Thank you very much.  I did just this, and 'am happy with the solution.  
Thanks a ton. -Shefali

> Hello shefali,
>
[quoted text clipped - 46 lines]
> >>> Matt Berther
> >>> http://www.mattberther.com

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.