I am encountering a "403 - Forbidden: Access is denied" error when attempting to upload a CSV file or data containing more than 437 rows (size: 8KB) in my ASP.NET MVC C# application? The website is hosted on AWS EC2 instance.
Loading
I am encountering a "403 - Forbidden: Access is denied" error when attempting to upload a CSV file or data containing more than 437 rows (size: 8KB) in my ASP.NET MVC C# application? The website is hosted on AWS EC2 instance.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Aman GuptaPosted Sep 10, 2024, 4:10 PM
Hi Bilal,
To answer your question on how to find the destination folder you need to follow these steps.
Determine the Physical Path of the Folder: To determine the physical path of the upload folder on your server:
Use Server.MapPath in a test method to print out the exact path.
Log the Path to Check: Add logging to see where the files are being uploaded. You can use Console.WriteLine.
Locate the Folder on AWS EC2 Instance
Connect to the EC2 Instance: Use SSH or RDP to log into the EC2 instance hosting your application.
For Windows EC2 instances, use Remote Desktop.
For Linux-based EC2 instances, use SSH.
Check the Application Root Directory:
Navigate to your website's root directory (usually inside C:\inetpub\wwwroot for IIS or /var/www/html for Linux setups).
Find the folder where your application is hosted and look for the Uploads folder or whatever folder you have configured in your code.
Permissions for the Folder: Once you've located the folder, ensure that the permissions are set properly:
For Windows:
Right-click the folder → Properties → Security → Ensure that the IIS_IUSRS group or your application pool identity has Write permissions.
For Linux:
Use the chmod command to set the appropriate permission
Verify in Application Logs: You can also check your server logs (IIS logs, application logs) to see if there are any issues related to the file upload path.
Let me know if this helps you locate the folder!
Aman GuptaPosted Sep 10, 2024, 4:04 PM
Hi Bilal,
There might be more things that need to be checked, but that depends on your usage if you are using for not.
Bilal ChoudharyPosted Sep 10, 2024, 7:51 AM
Hi Aman,
Thank you very much for your response. I'm glad the information was helpful.
If you've thoroughly checked points 1, 2, and 4, and all the necessary settings and limits are configured correctly, then we can focus on point 3.For point 3, if smaller files are being processed correctly, it's likely not a path issue. However, it's still a good idea to verify the destination path folder to ensure there are no hidden issues. Can you please guide how to find the destination folder.
Aman GuptaPosted Sep 10, 2024, 5:54 AM
Hi Bilal,
The issue you are facing might nbe because of server or application-level configurations.
1. IIS Request Filtering or Upload Limit:
2. AWS Security Group and NACL Configuration
3. File Permissions on EC2 Instance
4. Check AWS EC2 Instance Limits
Thanks