Windows 2003, IIS 6, FileStream, UnauthorizedAccessException

by bill 4/2/2007 8:22:00 PM

Hopefully, if you are getting an UnauthorizedAccessException in IIS 6 while trying to write out a file this will help you.

Today a client was frustrated after rolling out an application from staging to live.  The web application created thumbnails on the fly and caches those thumbnails to disk using a FileStream.  The code worked fine in the dev environment and in the staging environment, but as soon as it went to the live server it started throwing an UnauthorizedAccessException whenever the file was being written.

After searching Google for the terms in this posts subject I finally came across what I thought might fix the problem, sure enough it did. The IIS_WPG group must have the correct rights in the folder you are trying to write files to.

---------------------- Snip of the error -------------------
UnauthorizedAccessException: Access to the path '[THE_PATH_WAS_HERE]' is denied.]
System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) +2013027
System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy) +998
System.IO.FileStream..ctor(String path, FileMode mode) +65

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: ,

Powered by BlogEngine.NET 1.3.1.0
Theme by Mads Kristensen

About the author

Name of author Bill Rodenbaugh
I bang on the keyboard and somehow the end result turns into some kind of thing that sometimes does something.

E-mail me Send mail
View Bill Rodenbaugh's profile on LinkedIn

Calendar

<<  August 2008  >>
MoTuWeThFrSaSu
28293031123
45678910
11121314151617
18192021222324
25262728293031
1234567

View posts in large calendar

Recent comments

Authors

Categories

None


Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2008

Sign in