asp.net mvc - HTTP Handler in MVC Project Yielding 404s -


i've created mvc project on button click it's suppose save contents of the page .xlsx file. works fine in chrome/ff not in ie 9 , below.

to handle edge case i've implemented http handler. weird thing when in debugging (vs 2013) "without breakpoints" code works fine , i'm able download excel file in ie. when i'm not debuging , browse page 404: requested url: /home/exporthandler.axd wonder why getting 404 , why route electing put /home in url, there way remove it? ways here's code:

http handler

    namespace mvcapplication2 {     public class exporthandler : ihttphandler     {         public void processrequest(httpcontext context)         {             if (context.request.form["contenttype"] != null &&                context.request.form["filename"] != null &&                context.request.form["data"] != null)             {                 context.response.clear();                 context.response.contenttype = context.request.form["contenttype"].tostring();                 context.response.charset = "utf-8";                 context.response.expires = 0;                 context.response.appendheader("content-transfer-encoding", "binary");                 context.response.appendheader("content-disposition",                                               "attachment; filename=" + context.request.form["filename"].tostring());                 context.response.binarywrite(convert.frombase64string(context.request.form["data"].tostring()));                 context.response.flush();                 context.response.end();             }         }         public bool isreusable         {             { return false; }         }     } } 

mvc route

public class 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 }         );     } } 

web.config

    <location path="files">     <system.web>     <httpruntime targetframework="4.5" />     <compilation debug="true" targetframework="4.5" />     <authentication mode="forms">       <forms loginurl="~/account/login" timeout="2880" />     </authentication>     <pages>       <namespaces>         <add namespace="system.web.helpers" />         <add namespace="system.web.mvc" />         <add namespace="system.web.mvc.ajax" />         <add namespace="system.web.mvc.html" />         <add namespace="system.web.optimization" />         <add namespace="system.web.routing" />         <add namespace="system.web.webpages" />       </namespaces>     </pages>     <profile defaultprovider="defaultprofileprovider">       <providers>         <add name="defaultprofileprovider" type="system.web.providers.defaultprofileprovider, system.web.providers, version=1.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35" connectionstringname="defaultconnection" applicationname="/" />       </providers>     </profile>     <membership defaultprovider="defaultmembershipprovider">       <providers>         <add name="defaultmembershipprovider" type="system.web.providers.defaultmembershipprovider, system.web.providers, version=1.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35" connectionstringname="defaultconnection" enablepasswordretrieval="false" enablepasswordreset="true" requiresquestionandanswer="false" requiresuniqueemail="false" maxinvalidpasswordattempts="5" minrequiredpasswordlength="6" minrequirednonalphanumericcharacters="0" passwordattemptwindow="10" applicationname="/" />       </providers>     </membership>     <rolemanager defaultprovider="defaultroleprovider">       <providers>         <add name="defaultroleprovider" type="system.web.providers.defaultroleprovider, system.web.providers, version=1.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35" connectionstringname="defaultconnection" applicationname="/" />       </providers>     </rolemanager>      <sessionstate mode="inproc" customprovider="defaultsessionprovider">       <providers>         <add name="defaultsessionprovider" type="system.web.providers.defaultsessionstateprovider, system.web.providers, version=1.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35" connectionstringname="defaultconnection" />       </providers>     </sessionstate>     <httphandlers>       <add type="mvcapplication2.exporthandler" verb="*" path="exporthandler.axd" />     </httphandlers>   </system.web>   </location> 


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -