ASP.net MVC4 WebApi route with file-name in it

前端 未结 3 720
温柔的废话
温柔的废话 2020-12-01 10:10

I\'m trying to get the following (and similar) urls to work in my ASP.net MVC4/WebApi project:

http://127.0.0.1:81/api/nav/SpotiFire/SpotiFire.dll

相关标签:
3条回答
  • 2020-12-01 10:46

    You could add the following handler to the <handlers> section of your <system.webServer>:

    <add 
        name="ManagedDllExtension" 
        path="api/nav/*/*.dll" 
        verb="GET" 
        type="System.Web.Handlers.TransferRequestHandler" 
        preCondition="integratedMode,runtimeVersionv4.0" 
    />
    

    This will make all requests containing .dll be served through the managed pipeline. Also notice how I have limited them only to the GET verb to limit the performance impact.

    0 讨论(0)
  • 2020-12-01 10:51

    My trade off was to append /end to the end of route. .'s are ignored before the last /.

    The equivalent URL would be http://127.0.0.1:81/api/nav/SpotiFire/SpotiFire.dll/end.

    The benefit being that you don't get a performance hit on your assets.

    0 讨论(0)
  • 2020-12-01 11:07

    Found it. What's needed is this (and maybe some of the things I've added above in the original post):

    <system.webServer>
      <modules runAllManagedModulesForAllRequests="true" />
    </system.webServer>
    
    0 讨论(0)
提交回复
热议问题