Last post Sep 06, 2012 05:31 PM by Kaius
Sep 06, 2012 04:32 PM|Kaius|LINK
I would like to make a question about a problem i'm facing in an Asp.Net application. Everything works perfectly when i'm using the development machine, however, when i deploy the app, the erro below appear:
"System.UnauthorizedAccessException: Access to the path is denied.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at 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, Boolean useLongPath)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access)
at ServiceDesk.GestaoMudanca.BacklogDetalhado.btnLiberar_Click(Object sender, ImageClickEventArgs e) in C:\Users\caio.santanna\Documents\Visual Studio 2010\Projects\xxxxxxxxx\xxxxxxxxxxxxx.aspx.cs:line 412"
and thats the line that generates de error, the moment in wich the file is written...
System.IO.FileStream fsArquivo = new System.IO.FileStream(PathArquivo, System.IO.FileMode.Create, System.IO.FileAccess.Write)
I understand that i'm getting this because of access restrictions, but i allready tried to give permissions to some windows acc's (based on web research). By reading to that, i discovered that the acc that has to have access to the path is the one beeing
used by the application pool (right ?), in my case, the default one... Network Service. Even when i give permissions to that user, not only on the folder, but on the whole hierarchy of folders nothing seems to change and i still get the error.
I also tried to give permissions to IIS_WPG and IIS (just to see the result), but the error still appearing. The app is configured to work with windows authetication (an intranet's resource)
<authentication mode="Windows" />
<identity impersonate="true" />
So i would like to ask for a help on this case, since the user on the application pool doesn't worked.
Thanks for the help and sorry for my english, its not my main language.
Sep 06, 2012 05:31 PM|Kaius|LINK
My bad, i realize sometinhg (does not solve my problem, but...), the Network Service account would be used only if i'm not using impersonate, correct ? So, how can i make the correct configuration ? I mean, i need to use impersonate, otherwise code like
would not work (or at least i dont know how to make this work without impersonate).