2

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);
  }
Csharp
  • 177
  • 4
  • 15

2 Answers2

0

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

IIS_IUSRS

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

Community
  • 1
  • 1
Sushil Mate
  • 583
  • 6
  • 14
  • It is a shared hosting of winhost.So i can see that folder only from ftp login in filezilla.and when i right click in filezilla listing directory all the permission check boxes are already checked for read/write permission.is there any other way to get access in shared hosting of win host? can we set that access in win host account portal.because i didn't found any type of settings in win host account. – Csharp Jul 09 '16 at 09:47
  • ok. try using impersonation in Web.config then give access to the impersonated user. – Sushil Mate Jul 09 '16 at 09:57
  • I found the solution i moved upload folder to App_data .here is a link: – Csharp Jul 09 '16 at 17:37
0

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

Community
  • 1
  • 1
Csharp
  • 177
  • 4
  • 15