c# - Capture response of form post with input[type="file"] -
i have following html code:
<form action="@url.action("savepicture", "pictures")" method="post" enctype="multipart/form-data" id="savepictureform" target="my_iframe"> <input type="file" name="file" class="fileupload" multiple accept="image/*" /> </form> <iframe name="my_iframe" id="my_iframe" src="" class="hhidden"></iframe>
the form
used upload images. problem web.config
on server has file content size limitation.
if upload file of 10mb yet server accepts maximum 5mb, error.
here's how error looks in chrome:
i handle error in global.asax.cs
this
protected void application_error(object sender, system.eventargs e) { var exle = context.server.getlasterror() system.web.httpexception; if (exle != null && exle.webeventcode == system.web.management.webeventcodes.runtimeerrorposttoolarge) { handleposttoolargeerror(); } } private void handleposttoolargeerror() { server.clearerror(); this.context.response.clearheaders(); this.context.response.clearcontent(); this.context.response.statuscode = 503; this.context.response.status = "503 image large"; this.context.response.statusdescription = "image large"; this.context.response.flush(); this.context.response.end(); }
my problem browsers except internet explorer display dialog message "image large".
internet explorer handles internally form post, gets 503
error code nothing. (i can see in developer tools
, network
tab)
here's ie's form post response captured developer tools/network
yet error seen in ie's developer tools, user cannot guess what's wrong.
i need solution inform user upload failed specific reason, yet cannot find solution problem.
is possible capture response of form post , display user?
Comments
Post a Comment