简体   繁体   中英

Access to the path is denied

I have written code to upload excel files in .net MVC web application. its working fine on local host as not working on win host server its catching error Access to the path in denied.I already grant permission and added full control in filezilla folder listing.but still showing error : Access to the path is denied .Is there any thing i missed where i need to grant permission.

My code is as below:

  String laborpath="~/ExcelUploads/Labor_Excel/";
  String filename=Request.Files["FileUpload1"].FileName
  string filePath= string.Format(Server.MapPath(laborpath)+ filename); 
  foreach (string inputTagName in Request.Files)
  {
   HttpPostedFileBase Infile = Request.Files[inputTagName];
   Infile.SaveAs(filePath);
  }

Right click on your folder on your server or local machine and give full permissions to

IIS_IUSRS

https://stackoverflow.com/a/21498502/2745294

I found solution , i just moved target directory to App_data folder and its worked for me.here is a reference link :

ASP.net Getting the error "Access to the path is denied." while trying to upload files to my Windows Server 2008 R2 Web server

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM