Image Download - Local Host Abort

I have implemented a small method for my site where I upload an image. using the FileUpload control, I select an image, and then when I click the button, the UploadImage() method is generated.

The UploadImage() method saves the image in a folder on the server and saves its path in the database. It also checks the image file size if it exceeds megabytes, a warning is displayed, otherwise the image is downloaded and saved. This has been tested with multiple images from 45 KB to 900 KB. It worked great.

PROBLEM:

When testing with multiple images of approximately 4 MB, sometimes it shows an “error”, since it is more than 1 MB, but at other times (I don’t know why) Google Chrome directs me to a page that says that localhost was interrupted.

When debugging, I can’t even enter the "Download Click" button! I find it very strange. Image expansion does not seem to be a problem since I am testing with .jpg and .png.

Has anyone experienced the same problem? Is there a guru who can help me?

Thank you very much.


update:

it seems that 4052kb files worked correctly (i.e. an error message was displayed) but files over 4098KB) interrupted the local host. When the button is clicked, the browser below shows “send request” and download (0%) and displays “Connection to local host has been disconnected”.

+4
source share
1 answer

Note the maxRequestLength of the httpRuntime web.config element.

http://msdn.microsoft.com/en-us/library/e1f13641.aspx

Here you set the maximum request length. When it is exceeded, the runtime throws an exception. The default size is 4096 KB.

+6
source

Source: https://habr.com/ru/post/1381029/


All Articles