Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 850 Vote(s) - 3.49 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ASP.net MVC4 WebApi route with file-name in it

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

[To see links please register here]


The route responsible for this url looks like this:

config.Routes.MapHttpRoute(
name: "Nav",
routeTemplate: "api/nav/{project}/{assembly}/{namespace}/{type}/{member}",
defaults: new { controller = "Nav", assembly = RouteParameter.Optional, @namespace = RouteParameter.Optional, type = RouteParameter.Optional, member = RouteParameter.Optional }
);

It works just fine if I remove the . in the file-name, or if I add a slash behind the URL, but that also means I can't use the `Url.Route`-methods etc. The error I get is a generic 404-error (image below).

![enter image description here][1]

I've tried adding `<httpRuntime targetFramework="4.5" relaxedUrlToFileSystemMapping="true" />` to my web.config, and I've also tried adding

<compilation debug="true" targetFramework="4.5">
<buildProviders>
<remove extension=".dll"/>
<remove extension=".exe"/>
</buildProviders>
</compilation>

And none of it seems to work. So my question is basically, how can I get this URL to work, and map correctly?


[1]:
Reply

#2
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>
Reply

#3
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.
Reply

#4
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.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through