I am using MVC WebImage helper
var image = WebImage.GetImageFromRequest();
It seems like the image is only allowed in image formats and there is a maximum size that is allowed set on the image.
for example, if I try to upload an "image" with extension .exe, it will be the same as
if (image == null)
which clearly isn't true, but WebImage helper seems to mark all non-image formats as null.
and if i try to upload an image that is too large, it will throw an error even though I didn't set any restrictions on the size of the image.
So my question
First: Maximum file size define on the WebServer level. So if you want to change it the best way for whole application is to change it in Web.config
, maxRequestLength
. Ex:
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" maxRequestLength="2147483647" executionTimeout="1600" requestLengthDiskThreshold="2147483647" />
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="2147483647" />
</requestFiltering>
</security>
</system.web>
Second: The WebImage helper will attempt to return an image from any file that has an image MIME type.
So if you talking about extensions.
Following file types are accepted: ".jpg", ".png", ".bmp", & ".gif"
Following file types are not supported: ".ico", any non-image related file extension.