Can write local but not global

Snosky

Member
Joined
Dec 28, 2005
Messages
17
Programming Experience
1-3
Hi I have created a application and in this application you create a temporary file.
At first it gave an error like set impersonate="true" but I have supressed it by doing this temporary in the vb code
This works at the local server
Now I have released it on another server and tested it on a client.
It gave the same error (see bottom of this post).

does anyone know what the problem is?

Thank you in advance

error code
VB.NET:
[B]Server Error in '/lapp' Application. [/B]
 
[B][I]Access to the path "C:\inetpub\wwwroot\lapp\tempVCal.vcs" is denied.[/I] [/B]
 
[FONT=Arial, Helvetica, Geneva, SunSans-Regular, sans-serif][B][FONT=Verdana]Description: [/FONT][/B]An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 
 
[B][FONT=Verdana]Exception Details: [/FONT][/B]System.UnauthorizedAccessException: Access to the path "C:\inetpub\wwwroot\lapp\tempVCal.vcs" is denied. 
 
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. 
 
To grant ASP.NET write access to a file, right-click the file in Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access.
 
[B][FONT=Verdana]Source Error:[/FONT][/B] 
 
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. 
[B][FONT=Verdana]Stack Trace:[/FONT][/B] 
 
[UnauthorizedAccessException: Access to the path "C:\inetpub\wwwroot\lapp\tempVCal.vcs" is denied.]   System.IO.__Error.WinIOError(Int32 errorCode, String str) +393   System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean useAsync, String msgPath, Boolean bFromProxy) +888   System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize) +44   System.IO.StreamWriter.CreateFile(String path, Boolean append) +55   System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize) +49   System.IO.StreamWriter..ctor(String path) +60   Verlofdagen.WebForm1.createApp() +110   Verlofdagen.WebForm1.btnSendApp_Click(Object sender, EventArgs e) +4062   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33   System.Web.UI.Page.ProcessRequestMain() +1292
 
[B][FONT=Verdana]Version Information:[/FONT][/B] Microsoft .NET Framework Version:1.1.4322.2300; ASP.NET Version:1.1.4322.2300 [/FONT]


code I used to suppress
VB.NET:
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] winId [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] WindowsIdentity = HttpContext.Current.User.Identity
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] ctx [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] WindowsImpersonationContext = [/SIZE][SIZE=2][COLOR=#0000ff]Nothing
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] writer [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.IO.StreamWriter
ctx = winId.Impersonate()
System.IO.File.create("C:\inetpub\wwwroot\lapp\tempVCal.vcs")
[/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].Response.Redirect("done.aspx", [/SIZE][SIZE=2][COLOR=#0000ff]True[/COLOR][/SIZE][SIZE=2])
[/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Not[/COLOR][/SIZE][SIZE=2] ctx [/SIZE][SIZE=2][COLOR=#0000ff]Is[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Nothing[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Then
[/COLOR][/SIZE][SIZE=2]ctx.Undo()
[/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If
[/COLOR][/SIZE]
 
Back
Top