c# - Using the dot "." character in MVC4 Routes -


i serving images database tables of same file type. character dot "." in routes, have not had success doing so. understanding isapi handlers causing issue related this. i'm unsure how go adding , exclusion allow route handled asp.net.

routes.maproute(     name: "imageurl",     url: "image/{action}/{id}.png",     defaults: new { controller = "image" } ); 

you 404 errors because there no specific managed handler mapped path *.png in iis configuration. requests image/*.png paths intercepted staticfile modules (staticfilemodule, defaultdocumentmodule, directorylistingmodule) , these modules can not find requested files.

you can workaround problem configuring application in web.config.

the first option add runallmanagedmodulesforallrequests="true" attribute configuration/system.webserver/modules element. should looking this:

    <modules runallmanagedmodulesforallrequests="true" /> 

note: recommend not doing this. read more possible performance problems.

so the second (and better) option register asp.net isapi handling requests image/*.png path:

<system.webserver>   <handlers>     <add name="imagemvchandler-isapi-4.0_32bit" path="image/*.png" verb="get,head" modules="isapimodule" scriptprocessor="%windir%\microsoft.net\framework\v4.0.30319\aspnet_isapi.dll" precondition="classicmode,runtimeversionv4.0,bitness32" responsebufferlimit="0" />     <add name="imagemvchandler-isapi-4.0_64bit" path="image/*.png" verb="get,head" modules="isapimodule" scriptprocessor="%windir%\microsoft.net\framework64\v4.0.30319\aspnet_isapi.dll" precondition="classicmode,runtimeversionv4.0,bitness64" responsebufferlimit="0" />     <add name="imagemvchandler-integrated-4.0" path="image/*.png" verb="get,head" type="system.web.handlers.transferrequesthandler" precondition="integratedmode,runtimeversionv4.0" />   </handlers> </system.webserver> 

Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

c++ - Clear the memory after returning a vector in a function -

erlang - Saving a digraph to mnesia is hindered because of its side-effects -