Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
I try to upload file of 4Mb after click on upload button it give me below error

Error :
Application Error: Sorry page, you are looking for is not found in asp.net mvc


i have written no validation code that will check size of file ,but it giving me this issue

2.32MB file get uploaded successfully

Following is my code

<input style="display:inline-block;" type="file" name="excel_file" id="excel_file" accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel">


and following function called after upload button click

function ValidateFields() {
            if ($("#ddval").val() == "") {// || $("#excel_file").val() == "") {
                alert("Please select action");
            }
            else if ($("#excel_file").val() == "") {
                alert("Please select file");
            }
            else {
                frmImportExcelDetails.submit();
            }
            return false;
        }


please help me on this

What I have tried:

i tried many thing but still it giving me error
Posted
Updated 18-Jun-23 23:01pm

In IIS, the maximum request size is 4Mb. If you try to upload a file one byte larger, you will get a 404 error.

You need to modify the request limits to allow for larger file uploads. That means modifying your web.config file in two places:
XML
<configuration>
    <system.web>
        <httpRuntime maxRequestLength="10240" />
    </system.web>
</configuration>
XML
<system.webServer>
   <security>
      <requestFiltering>
         <requestLimits maxAllowedContentLength="1048576" />
      </requestFiltering>
   </security>
 </system.webServer>
NB: The setting under system.web is in kilobytes, whereas the one under system.webServer is in bytes. So to make them match, the second needs to be equal to 1024 × the first.

With this config in place, you will be able to upload files up to 10Mb. If you need to support larger files, then increase the values - you can set any value up to approximately 2Gb.
 
Share this answer
 
The error message you are getting is a 404 error: page not found. That has nothing to do with the code you show, it means that the page the user (or a redirect) is trying to access has an incorrect URL and cannot be located.

I'd start by looking at the URL ...
 
Share this answer
 
Comments
Akshay malvankar 19-Jun-23 0:01am    
then why it not throw error while uploading 2 mb file ,if page is not there then same error should be giving while uploading 2mb files also

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900