I'm using url rewriting.net. I'm testing web on the local host, it is successfully work. But When i deploying web to remote host, url rewriting not work. Problem is (The resource cannot be found). I found problem. My deployed remote host IIS configuration is (Virtual dir->Properties->Home directory->Application Mapping->.aspx->Edit->"Check that file exist" is checked). I need to uncheck them. But my deployed host control panel not have a application mapping function.
How to uncheck this option using web.config?
Is it possible?
Has you another idea?
IIS6
If this is IIS6 then unfortunately there is no way to change the script map settings via your ASP.NET web.config file.
You would need to find a hoster that permitted this configuration change via their control panel, or ask your present hoster (nicely) to change this for you.
IIS7
If this is IIS7 then you need to add (if it doesn't already exist) a <system.webServer /> configuration section to your web.config file and modify the handler behaviour:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<!-- remove existing handlers -->
<remove name="PageHandlerFactory-ISAPI-2.0" />
<remove name="PageHandlerFactory-Integrated" />
<!-- add back but set resourceType="Unspecified" to prevent
checking if file exists -->
<add name="PageHandlerFactory-ISAPI-2.0"
resourceType="Unspecified"
path="*.aspx"
verb="GET,HEAD,POST,DEBUG"
modules="IsapiModule"
scriptProcessor="%windir%\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll"
requireAccess="Script"
preCondition="classicMode,runtimeVersionv2.0,bitness32"
responseBufferLimit="0" />
<add name="PageHandlerFactory-Integrated"
resourceType="Unspecified"
path="*.aspx"
verb="GET,HEAD,POST,DEBUG"
type="System.Web.UI.PageHandlerFactory"
preCondition="integratedMode" />
</handlers>
</system.webServer>
</configuration>
This will only work if your hoster has delegated read/write access to the Handler Mappings feature.
I'd be fairly surprised though if this was IIS 7 and the PageHandlerFactory-ISAPI-2.0 and PageHandlerFactory-Integrated handler were configured as resourceType="File" or resourceType="Either". Out of the box they're configured not to check for the existence of files and folders.
Related
From what I understand this error occurs when the web.config is not configured properly. However when I publish the app the following web.config gets generated
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath=".\Lotus.Server.exe" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
</system.webServer>
</location>
</configuration>
<!--ProjectGuid: 85a43eb6-3576-401d-b025-a15a2cc377b6-->
I first thought of installing URL Rewrite, this did not solve the problem. I am stressing out have tried almost everything any ideas on how to resolve it?
The error page looks like this:
I had this same problem and I was trying to fix it for 4 days. Then I found the solution.
Firstly you need to download dotnet hosting 2.2.2
https://dotnet.microsoft.com/download/dotnet-core/thank-you/runtime-aspnetcore-2.2.2-windows-hosting-bundle-installer
Then after instalation try to restart IIS with cmd (run as admin and then write iisreset).
If error page has changed we are going in good direction :)
Now it should say that you are using wrong module (which indeed is true).
Open IIS, get to your website and check installed modules. On list you should be able to see AspNetCoreModule but not AspNetCoreModuleV2.
go to:
%ProgramFiles%\IIS\Asp.Net Core Module\V2\
and copy aspnetcorev2.dll
Then go into %SystemRoot%\system32\inetsrv\ and paste it
Now after this, open config folder in %SystemRoot%\system32\inetsrv\ and then open applicationHost.
IMPORTANT
At this stage you need to turn off your iis
Now find this line:
<add name="AspNetCoreModule" image="%SystemRoot%\system32\inetsrv\aspnetcore.dll" />
and add under it:
<add name="AspNetCoreModuleV2" image="%SystemRoot%\system32\inetsrv\aspnetcorev2.dll" />
And this same goes with this one:
<add name="AspNetCoreModule" />
add under it:
<add name="AspNetCoreModuleV2" />
Now save it, overwrite old one, and enable IIS. Go to your website, check modules and at the list you should be able to see AspNetCoreModuleV2:
AspNetCoreModule and AspNetCoreModuleV2 on list
For me It was lacking the Url Rewrite Module
https://www.freecodecamp.org/news/how-to-deploy-a-blazor-application-on-internet-information-services-iis-f96f2969fdcb/
Fixed this by changing "AspNetCoreModuleV2" to "AspNetCoreModule" in the generated web.config in my publish folder, i.e., from
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
to
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
This had me scratching my head for a while as everything was working fine on LocalHost - the error occured on the production server.
After rebuilding the site I realised that I had deleted the site folder on the production server along with its contents.
When I replaced the site I had posted it to my server node without recreating the site folder, so obviously the server couldn't access my web.config file as it was unbable to find the site folder.
Lesson learnt! Hope it saves other running down the 500.19 rabbit hole.
We have an ASP.NET Core 2.0 web site that also presents a couple of simple Web API methods for UI enhancement purposes.
The Web API calls work as expected when running locally under IIS Express, but when we deploy to our IIS 8.5 production web server, we get the following error when making HTTP DELETE and PUT requests...
405 Method Not Allowed
After some web searching, we have found several posts suggesting the removal of the IIS WebDAV module. We have disabled this in IIS (it is our server), and we have also tried the following:
Disabled WebDAV
Enabled WebDev and set Allow verb filtering = False
Set the Hander Mappings to allow All Verbs in the Request Restrictions settings for: aspNetCore, WebDAV and ExtensionlessUrlHandler-Integrated-4.0
None of the above steps have resolved our problem.
Any advice/direction would be much appreciated.
This was what worked for me (netcore 2.0)
<system.webServer>
<modules runAllManagedModulesForAllRequests="false">
<remove name="WebDAVModule" />
</modules>
</system.webServer>
Found here: https://www.ryadel.com/en/error-405-methods-not-allowed-asp-net-core-put-delete-requests/
After hours of research and trial and error, the fix seems to be pretty simple. Add a Web.config file to your .NET Core 2.0 application:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<!-- To customize the asp.net core module uncomment and edit the following section.
For more info see https://go.microsoft.com/fwlink/?linkid=838655 -->
<system.webServer>
<modules>
<remove name="WebDAVModule" />
</modules>
<handlers>
<remove name="aspNetCore" />
<remove name="WebDAV" />
<!-- I removed the following handlers too, but these
can probably be ignored for most installations -->
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<remove name="OPTIONSVerbHandler" />
<remove name="TRACEVerbHandler" />
<add name="aspNetCore"
path="*"
verb="*"
modules="AspNetCoreModule"
resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="%LAUNCHER_PATH%"
arguments="%LAUNCHER_ARGS%"
stdoutLogEnabled="false"
stdoutLogFile=".\logs\stdout" />
</system.webServer>
</configuration>
Hope this helps.
Whilst removing WebDAV may solve your issue, you may be wondering (like I was), what is WebDAV and what is it used for?
I found this page which helps explain it:
https://www.cloudwards.net/what-is-webdav/
To prevent WebDav from getting enabled at all, remove the following entry from the ApplicationHost.config:
<add name="WebDAVModule" />
The entry is located in the modules section.
Exact location of the config:
C:\Windows\System32\inetsrv\config\applicationHost.config
This worked well for me in .Net Core 2.1
In my case, I got the 405 error for .Net 5 Web API PUT and DELETE calls. I tried multiple solutions like removing WebDAV (Turn Windows features on or off -> IIS -> World Wide Web Services -> Common HTTP feature -> WebDAV Publishing) doesn't work, editing WebDAV entry in "Handler Mappings" messed up the application.
Solution
In IIS, select the application
Add rules to allow HTTP verbs in Request Filtering (But this alone doesn't work).
Go to "Modules", then select the "WebDAV Publishing" module and remove it.
Go to "Handler Mappings", then select the "WebDAV" and remove it.
in cmd run IISRESET
Add the following lines to your web.config file. That does it.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<modules>
<remove name="WebDAVModule" />
</modules>
<handlers>
<remove name="WebDAV" />
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,PUT,DELETE,DEBUG" type="System.Web.Handlers.TransferRequestHandler" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode,runtimeVersionv4.0" responseBufferLimit="0" />
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\Ftms.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
</system.webServer>
</location>
</configuration>
Remove the WebDAV Publishing from IIS server. Its come under the Internet Infromation service -> Common Http Features
https://ignas.me/tech/405-method-not-allowed-iis/
In my case, I resolved the issue after I add requireAccess="None" to aspNetCore handler
Like this :
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" requireAccess="None" />
For me, I resolved the issue after I noticed I was trying to post to the client domain instead of the API. [facepalm]
I didn't even have a mapping for aspnetcore under Handler Mappings in IIS. It made me open Visual Studio Installer and install Development time IIS support under .NET cross-platform development. Then, the aspnetcore handler mapping showed up in IIS.
If you're developing with recent ASP.NET Core version and using development server it's likely that it's not a WebDAV issue at all.
Make sure that your routes and HttpDelete/HttpPut attributes are set correctly. Otherwise you'll get the same or similar errors if the method is simply mismatched (e.g. route to a HttpGet one was chosen).
After long research on the internet, I solved it as follows;
<configuration>
<system.webServer>
<modules>
<remove name="ModSecurity IIS (64bits)" />
<remove name="ModSecurity IIS (32bits)" />
</modules>
</system.webServer>
To prevent WebDav from getting enabled at all, remove or comment the following entry from the ApplicationHost.config:
<add name="WebDAVModule" />
The entry is located in the modules section.
Exact location of the config:
C:\Windows\System32\inetsrv\config\applicationHost.config
This worked well for me in .Net Core 2.2
I use a httphandler to remap browser Urls to files in my website. This works fine but I am having trouble accessing files I created under a new directory. The url looks like this:
http://mobile.mysite.com/monitoring/help/help.aspx
Yet the information returned in the 404 error shows it cannot find the file under:
D:\Sites\Website\monitoring\help\help.aspx
Yet the file is really located under:
D:\Sites\Website\mobile\monitoring\help\help.aspx
My http handler normally recognizes the "mobile" subdomain. In fact, if I leave off the actual file and just use the directory, my handler does get called. Even if I put a breakpoint in my code, VS will never get called. Why is IIS accessing the help.aspx under a directory that doesn't exist? Why isn't my httphandler being called. As I mentioned, the httphandler does work for virtually every other file. I am able to call aspx file located under other domains.
This is how my handler looks in the web.config file:
<add name="FileServerHandler-Files" path="*.*" verb="*" type="FileServerHandler" modules="ManagedPipelineHandler" scriptProcessor="" resourceType="Either" requireAccess="Read" allowPathInfo="false" preCondition="" responseBufferLimit="4194304" />
Running ASP.NET 4.0 on IIS7
The subdomain "mobile" is actually mapped to the same IP address as the main site. Does this have something to do with it? If it does, it doesn't explain why the handler can access folders under the mobile domain but not aspx files.
While I had an entry in the web.config for the handler to handle directories, I tried moving it up in the list. This worked. Why it stopped working is a mystery as the web.config hasn't changed for a very long time. This is what the entries now look like:
<add name="FileServerHandler-Dir" path="*" verb="*" type="FileServerHandler" modules="ManagedPipelineHandler" scriptProcessor="" resourceType="Unspecified" requireAccess="Read" allowPathInfo="false" preCondition="" responseBufferLimit="4194304" />
<add name="FileServerHandler-Files" path="*.*" verb="*" type="FileServerHandler" modules="ManagedPipelineHandler" scriptProcessor="" resourceType="Either" requireAccess="Read" allowPathInfo="false" preCondition="" responseBufferLimit="4194304" />
I have website which I opened in Visual web developer express.
In web.config , I have a handler defined B.
<add verb="GET,POST" path="*/faq*" validate="false" type="DefaultRedirectHandler" />
How to specify the location DefaultRedirectHandler which is a dll in this environment?
I created a handler.dll which contains the class B derived from IHttpHandler in bin directory but there are signs it is not used.
Also, I tried
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<add name="ASP Wild" path="*" verb="*" modules="IsapiModule" scriptProcessor="C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" resourceType="Unspecified" requireAccess="None" preCondition="classicMode,runtimeVersionv4.0,bitness32" />
<add name="SampleHandler" verb="*"
path="*"
type="DefaultRedirectHandler,handler.dll"
resourceType="Unspecified" />
</handlers>
Is there some log I can look at if this handler is called elsewhere.
When you add your handler you should fully qualify its type. Include the namespace along with your type name.
<httpHandlers>
<add verb="*" path="*"
type="MyHandlerAssembly.With.A.NameSpace.IISHandler1, MyHandlerAssembly" />
</httpHandlers>
How to: Register HTTP Handlers
The assembly your handler is in must either exist in your web application's bin directory or the system assembly cache.
For more details on the configuration for HttpHandler's see the following.
add Element for httpHandlers (ASP.NET Settings Schema)
Keep in mind that there are many ASP.NET handlers added by default and defined by the system machine.config and root web.config (in your .NET library directory). If any of these handlers match your path they could be executed first. If they close the response then your handler may never get executed.
EDIT:
As for debugging what is going on on your server (i.e. what handlers in what order are getting called) you may be interested in checking out Glimpse.
I am having problems trying to map an HttpHandler in the web.config.
This is the relevant config bit:
<httpHandlers>
<add verb="*" path="*.hndlr" type="MyAssembly.MyHandler, MyAssembly" validate="false" />
</httpHandlers>
When I navigate to http://localhost/myApp/whatever.hndlr I am getting a server error 404 (not found).
It's the 1st time I am hooking up an HttpHandler so I might be missing something - any help appreciated!
UPDATE:
I managed to get it working using both answers so far - who's able to explain why it works gets the answer marked!
This is my config (won't work if you don't have both - I am running IIS7 in classic mode)
System.web:
<httpHandlers>
<add verb="*" path="*MyHandler.hndlr" type="MyAssembly.MyAssemblyHandler, MyAssembly" validate="false"/>
</httpHandlers>
System.webserver:
<handlers>
<add name="MyHandler" verb="*" path="*MyHandler.hndlr" type="MyAssembly.MyAssemblyHandler, MyAssembly" validate="false" modules="IsapiModule" scriptProcessor="C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll" resourceType="Unspecified" requireAccess="Script"/>
</handlers>
Are you using IIS7, if so is the application pool running in classic or pipelined mode? If it is IIS7 in pipelined mode then the handler reference needs to go into the following section
<system.webServer>
<handlers>
</handlers>
<system.webServer>
rather than in the following section.
<system.web>
<httpHandlers>
</httpHandlers>
</system.web>
Just as a guide for those stuck with this problem I found the crucial attribute to be..
resourceType="Unspecified"
I originally followed a Microsoft example to set this up and they had it as
resourceType="File"
which just kept giving me 404 errors. My HTTPHandler is returning graphics.
Hope this helps :)
i am using IIS7, the solution is:
in section
<system.web>
<httpHandlers>
<add verb="*" path="*.ashx" type="CVOS.MyDocumentHandler"/>
</httpHandlers>
<system.web>
and section
<system.webServer>
<handlers>
<add name="pdfHandler" verb="*" path="*.ashx" type="CVOS.MyDocumentHandler" />
</handlers>
</system.webServer>
What is the extension of your handler? If you are using a custom extension like .hndlr you may also need to add a ScriptMap in IIS and point it to the ASP.NET runtime so that IIS can forward the request to the correct processor.
In IIS7 go to your website
Under the IIS group go to Handler Mappings
Under Actions click Add Script Map
Set Request Path to *.hndlr
Set Path to the ASP.NET runtime (%windir%\Microsoft.NET\Framework64\v2.0.50727\aspnet_isapi.dll) or whatever version you are running.
Then in your web.config you will need to register the handler in the appropriate section as described in the other answer.
It is also possible to experience this error if you have set up the handler for 32 bit, but you are running in 64 bit (or vice versa). It's easy to set up both and have all the bases covered.
Note "preCondition", and "scriptProcessor" differences.
<handlers>
<add name="MyHandler_32bit" verb="*" path="*MyHandler.hndlr" preCondition="bitness32" type="MyAssembly.MyAssemblyHandler, MyAssembly" validate="false" modules="IsapiModule" scriptProcessor="C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" resourceType="Unspecified" requireAccess="Script" />
<add name="MyHandler_64bit" verb="*" path="*MyHandler.hndlr" preCondition="bitness64" type="MyAssembly.MyAssemblyHandler, MyAssembly" validate="false" modules="IsapiModule" scriptProcessor="C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" resourceType="Unspecified" requireAccess="Script" />
</handlers>
None of the previous answers worked for me.
I'm using IIS 8.5, .Net v4.0, Integrated, and was still getting a 404 with the following handler config:
<system.webServer>
<handlers>
<add name="testEmail" path="*.em" verb="*" type="MyApp.testRazorEmailHandler, MyApp" resourceType="Unspecified" requireAccess="Script" />
</handlers>
</system.webServer>
I enabled tracing and found the following :
116. -HANDLER_CHANGED
OldHandlerName testEmail
NewHandlerName System.Web.Mvc.MvcHandler
NewHandlerModules ManagedPipelineHandler
NewHandlerScriptProcessor
NewHandlerType System.Web.Mvc.MvcHandler, System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
As you can see it looks like it had correctly picked up the request using my custom HttpHandler testEmail but MVC had stolen it.
I opened my route definitions in RouteConfig.cs and found that adding:
routes.IgnoreRoute("{resource}.em");
I got it to ignore requests meant for my Handler.
Hope this helps someone - I was tearing my hair out!
Hopefully my solution will help others. On a server move from IIS6 to 7.5, both .Net 4.0 Integrated, I had a Captcha control that quit working. It turns out that removing this attribute preCondition="integratedMode,runtimeVersionv2.0" from the <add> node in <system.webserver><handlers> resolved the issue.
This seems to be an edge case, but I had a customer where our httpHandler used in our application did not work on any of their servers. The handler pointed to an .ashx page and it was called from JavaScript.
The handler mapping showed up in IIS, the handler factory was there, but I would get a 404 when the browser requested the ashx page associated with the handler. After many different attempts to fix we finally browsed to the file in IIS on the server and it specifically showed a 404.7 being returned with this message.
•Request filtering is configured for the Web server and the file extension for this request is explicitly denied.
•Verify the configuration/system.webServer/security/requestFiltering/fileExtensions settings in applicationhost.config and web.config.
If you get this then Request Filtering is enabled for the .ashx extension at either your app or site level. Go to the Request Filtering option in IIS at both your site and app level and verify that the extension is not blocked. There are two different ways Request Filtering can be configured.
The default seems to be that it explicitly blocks only file extensions that are configured in the list (blacklist). The other way it can be configured is that only files specifically configured as allowed in the list are let through (whitelist). This second option is how the customer had configured all of their Windows Servers by default and it turns out that the .ashx file extension was not in the list of allowed extensions.
This is the first thread that appears when I look for a verb that responds with a 404. In my case the solution was a configuration of VS
Tools > Options > Web projects > [x] Use 64 bit version
Sorry, my VS is in spanish