3

URLs with a dot generate a server error 404 (e.g. www.mysite.com/a.b). A solution is editing my site's HTTP handlers, with a new handler that looks for a specific path criteria. If the request matches it is correctly sent to .NET for processing. The handler is shown below.

<add name="ApiURIs-ISAPI-Integrated-4.0"
     path="*"
     verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS"
     type="System.Web.Handlers.TransferRequestHandler"
     preCondition="integratedMode,runtimeVersionv4.0" />

Because im using path="*", all static files like .css or .js fail and get blocked. My static files are in a /Content directory. Is there a way to exclude the directory from this?

Jelle
  • 758
  • 2
  • 14
  • 36
  • Have you read [this](https://stackoverflow.com/questions/11728846/dots-in-url-causes-404-with-asp-net-mvc-and-iis)? – Dave Barnett Aug 23 '20 at 12:40

1 Answers1

3

Try to add the below web.config file in the directory from where you want to remove the handler:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <handlers>
            <remove name="ApiURIs-ISAPI-Integrated-4.0" />
        </handlers>
    </system.webServer>
</configuration>

Refresh the site after doing changes.

Jalpa Panchal
  • 8,251
  • 1
  • 11
  • 26
  • This doesn't work for me. Any webpage becomes empty without content (they're all blank pages). – Jelle Aug 17 '20 at 06:46
  • @Jelle another option is you could use the location tag in your root config file: ` ` – Jalpa Panchal Aug 17 '20 at 07:08
  • @Jelle by using location tag it will apply the configuration setting to the specified folder or file which you mentioned in the path. – Jalpa Panchal Aug 17 '20 at 07:16
  • I'm confused about your location solution. The location path is on upload, is this supposed to be Content? Also there are path, verb, modules and requireAccess parameters, but remove doesn't allow these parameters, only add does. You also changed the handler name to StaticFile which confuses me more. – Jelle Aug 19 '20 at 10:08
  • @Jelle the comments show the just example. you could set based on your requirement. in the path set your folder name and path, in remove name handler set your handler name. – Jalpa Panchal Aug 24 '20 at 07:32