Problem with fileupload in visual studios 2005.

Discussion in 'ASP.NET / ASP.NET Core' started by wisystemcom, Aug 23, 2009.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. I am trying to get a file to upload using the fileupload object in visual studios 2005. It looks to me to be a permissions issue but when i use the control panel for discountaspnet the permissions seem to be correct. I have posted my code below and the error I am getting when I try to save the file. Any help would be much appreciated.

    Error and code

    Server Error in '/**FOLDER NAME EDITED**' Application.
    --------------------------------------------------------------------------------
    Access to the path 'E:\web\**SERVER NAME EDITED**\htdocs\**FOLDER NAME EDITED**\cust\CH16_F3.jpg' is denied.
    Description: 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.
    Exception Details: System.UnauthorizedAccessException: Access to the path 'E:\web\**SERVER NAME EDITED**\htdocs\**FOLDER NAME EDITED**\cust\CH16_F3.jpg' 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 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.
    Source Error:

    Line 5: Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
    Line 6: If FileUpload1.HasFile Then
    Line 7: FileUpload1.SaveAs(Server.MapPath("~/cust/") + FileUpload1.FileName)
    Line 8: End If
    Line 9: End Sub
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page