asp.net mvc 4 - File upload form with MVC4 Web-API: Getting Error 101 (net::ERR_CONNECTION_RESET): The connection was reset. Error -
asp.net mvc 4 - File upload form with MVC4 Web-API: Getting Error 101 (net::ERR_CONNECTION_RESET): The connection was reset. Error -
i'm getting webpage not available error when trying access controller action in mvc4 web-api app vs2010. trying upload little sized (less 1mb) pdf document, create byte[] pass on service. however, can't either normal controller or api controller. app works , views/partials/etc. show fine except 1 (the page file upload form). view typed partial.
i've tried using method shown here: upload file mvc 4 web api .net 4 here: http://blogs.msdn.com/b/henrikn/archive/2012/03/01/file-upload-and-asp-net-web-api.aspx , both of them don't work because action attribute can't find action. whether set api/documents or home/api/documents won't work. gave , went html helper beginform, hoping find way...but didn't. after giving on fancy web-api stuff (couldn't async work), figured i'd go old school , pass in file through form, same error. i've tried re-creating page, adjusting httphandlers, runtime adjustments, routes , apiroutes, , @ loss. please help!
my ui:
error:
my form:
<div class="tab-pane" id="adddoc"> @using (html.beginform("adddocument", "documents", formmethod.post, new { @class = "form-horizontal", @enctype = "multipart/form-data" })) { <label class="control-label" for="newfile">upload : </label> <input name="newfile" type="file" /> <input type="submit" value="submit" class="btn btn-success"/> } </div>
my api controller: know doesn't create sense, have breakpoint see if gets here, doesn't...
[httppost] public adddocumentresponse adddocument(httppostedfilebase newfile) { adddocumentresponse response = new adddocumentresponse(); homecoming response; }
my normal controller action:
[httppost] public actionresult adddocument(httppostedfilebase newfile) { homecoming view("devnotes"); }
my webapiconfig:
public static void register(httpconfiguration config) { config.routes.maphttproute( name: "defaultapi", routetemplate: "home/api/{controller}/{id}", defaults: new { id = routeparameter.optional } ); }
my routeconfig:
public static void registerroutes(routecollection routes) { routes.ignoreroute("{resource}.axd/{*pathinfo}"); routes.maproute( name: "default", url: "{controller}/{action}/{id}", defaults: new { controller = "home", action = "index", id = urlparameter.optional } ); routes.maproute( name: "default2", url: "home/{controller}/{action}/{id}", defaults: new { controller = "home", action = "index", id = urlparameter.optional } ); }
part of webconfig:
<httphandlers> <add path="*.less" verb="get" type="dotless.core.lesscsshttphandler, dotless.core" /> </httphandlers> <httpruntime executiontimeout="99009" maxrequestlength="2097151"/>
i have same error because of fiddler installed. when configured start proxy makes changes lan configuration works proxy , scheme won't work without fiddler. hope helps.
file-upload asp.net-mvc-4 asp.net-web-api interrupted-exception asp.net-web-api-routing
Comments
Post a Comment