Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exclude web config handler on specific directory

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?

like image 380
Jelle Avatar asked Jun 19 '26 00:06

Jelle


1 Answers

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.

like image 53
Jalpa Panchal Avatar answered Jun 22 '26 06:06

Jalpa Panchal



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!