I have a web application which talks to a local service (also mine) and produces results from the RESTful calls.
I have deployed the web application through IIS 7 on my system.
So far it looks fine, except that I am not able to perform POST operations, they just seem like NOP's.
Although, when I install VS 2012 on the machine the POST operations start working. I am not sure what exact thing the VS 2012 install sets which causes the POST operations to work.
Any hints?
You have to enable POST operations in your web.config file. A simple implementation is demonstrated below
<system.webServer>
<handlers>
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE" type="System.Web.Handlers.TransferRequestHandler" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
</system.webServer>
Make sure to inlcude this in your config file:
<webServices>
<protocols>
<add name="HttpGet"/>
<add name="HttpPost"/>
</protocols>
</webServices>
Related
I have got a new iis server and from a while i am finding solution for error :
405 - HTTP verb used to access this page is not allowed. The page you
are looking for cannot be displayed because an invalid method (HTTP
verb) was used to attempt access.
I have seen below solutions:
1.
<system.webServer>
<modules>
<remove name="WebDAVModule" />
</modules>
<handlers>
<remove name="WebDAV" />
</handlers>
</system.webServer>
2. IIS Settings http://www.somacon.com/p126.php
Solution 1, causes Internal server error and later unable to find the solution.
Solution 2, i am unable to find Property window in iis 8.5, so unable to try the same.
Please help
I also had the same internal server error when attempting the first solution, described at HTTP 405 error with Web API. Since I wasn't even using WebDAV, I opted to remove it entirely from IIS (see screenshot below). After a required server restart, the problem was resolved.
One of my colleague helped me out. I was missing some of the major iis features.
Goto Add Roles and Features Wizard, then Web Server (IIS)> Web Server > Application Development > Select ASP.net 3.5 and Asp.net 4.5 and click Install.
Goto cmd prompt and iisreset.
For WCF service, Kindly check Http Activation under WCF Services.
Hope this may help you and save your time.
This is late but may help some other guys.
My application is WEB-API dotnet Core face same problem when deploy on local server resolve this by doing following steps.
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<remove name="WebDAVModule"/>
<!-- add this -->
</modules>
<handlers>
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
<remove name="TRACEVerbHandler" />
<remove name="OPTIONSVerbHandler" />
<remove name="WebDAV" />
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<add name="aspNetCore" path="*" verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode,runtimeVersionv4.0" responseBufferLimit="0" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" resourceType="Unspecified" requireAccess="Script" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" resourceType="Unspecified" requireAccess="Script" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
</handlers>
I have faced the same issue with with my PHP application that runs on "Windows server 2019" and IIS server. I tried to test my FHIR APIs through Postman but only POST and GET request were working fine. But PUT requests were not working. Any solutions that were suggested to do on web.config file were not worked for me.
Only solution was to remove "WebDAV" module from IIS (as suggested by Mark G). Restarting the server machine is a MUST to apply that feature removal and make my application to work properly.
I am implementing a RESTful web services host using ASP.Net 4.5 and Web Api 2 Attribute Routing. I also included Web Api Help Pages. When I run it locally through Visual Studio 2012 on IIS Express it works great and looks really cool; it displays the default /home/index page with an API menu that shows the documentation for all my RESTful API functions. I have also tested all the API methods with SOAPUI and running locally everything works perfectly.
But the URL routing absolutely refuses to work when deployed to IIS 7.5 on Windows 2008 Server R2.
When I browse the site I get:
403 - Forbidden: Access is denied.
If I try the /home/index or any of the routes of my web api methods I get:
404 - File or directory not found.
I have installed .Net 4.5 on the server and then went to Windows\Microsoft.NET\Framework64 and ran:
Aspnet_regiis -i
iisreset
I deployed my app to IIS and set the Application Pool to use .Net Framework v4.0.30319 and Managed pipeline mode: Integrated.
I have the following settings in my web.config:
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
<authentication mode="None" />
<pages>
<namespaces>
<add namespace="System.Web.Helpers" />
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Optimization" />
<add namespace="System.Web.Routing" />
<add namespace="System.Web.WebPages" />
</namespaces>
</pages>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true" />
<handlers>
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
</system.webServer>
I have tried many different variations on the web.config entries. For example, the suggestion in this post does not work either:
<modules>
<remove name="UrlRoutingModule-4.0" />
<add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule" preCondition="" />
<!-- any other modules you want to run in MVC e.g. FormsAuthentication, Roles etc. -->
</modules>
Nor does changing the Handlers section like this have any effect:
<handlers>
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<remove name="OPTIONSVerbHandler" />
<remove name="TRACEVerbHandler" />
<remove name="WebDAV" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
<add name="MiniProfiler" path="mini-profiler-resources/*" verb="*" type="System.Web.Routing.UrlRoutingModule" resourceType="Unspecified" preCondition="integratedMode" />
</handlers>
I did try turning directory browsing on and then it showed the website contents just fine, so the 403 Forbidden error is because directory browsing was forbidden.
But I don't want to browse the contents, I want URL routing to work. In RouteConfig.cs file I have a default route:
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
So if URL routing were working then it should show the Home/Index view by default.
I also tried adding an Index.html file to the site and that worked fine too. So the website works fine as a website, but URL routing refuses to work.
Try to add this attribute to < modules > tag in web.config
runAllManagedModulesForAllRequests="true"
I'm trying to deploy a WebAPI project to Azure.
It works locally. When I Publish it to Azure, I get 404 on the controller routes.
Looking at the logs, I see the routes are being handled as static files, instead of going through my controllers.
Module IIS Web Core
Notification MapRequestHandler
Handler StaticFile
Error Code 0x80070002
Requested URL http://xxxxx:80/api/studies
Physical Path D:\home\site\wwwroot\api\studies
Logon Method Anonymous
Logon User Anonymous
My Global.asax is:
protected void Application_Start()
{
GlobalConfiguration.Configure(WebApiConfig.Register);
}
And my WebApiConfig.Register is:
public static void Register(HttpConfiguration config)
{
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
}
I've looked at similar questions and tried tweaking my Web.config to no avail. It currently looks like this (relevant part only):
<system.webServer>
<httpErrors existingResponse="PassThrough"/>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true">
</modules>
<handlers>
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<remove name="OPTIONSVerbHandler" />
<remove name="TRACEVerbHandler" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
</system.webServer>
By the way, I'm on Entity Framework 6 and not using MVC, just straight up WebAPI.
Somehow my Global.asax got excluded from the project, so the route mapping never happened.
I had the same issue. nothing else worked until changing my web config to look like this solved it for me
<handlers>
<remove name="WebDAV" />
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<remove name="OPTIONSVerbHandler" />
<remove name="TRACEVerbHandler" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
Have you checked all the necessary Windows Features for your server? Maybe some features are missing from IIS, for example:
Internet Information Services - World Wide Web Services - Application Development Features - ASP.NET.
You can find and check which features are installed on your machine by going to Windows Features (or going through the Server Manager if you're on a Windows Server).
If that is not your problem, it can sometimes be that ASP.NET is not installed properly. You can re-install ASP.NET by following this article: http://support.microsoft.com/kb/2736284 (it depends on your operating system).
I have a web application running in .net framework 2.0 and hosted on IIS 7.5. The app pool is running in classic mode. I want to intercept all the requests containing .txt files. Below is my entry in web.config
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<handlers>
<add name="NES.HiLo.Security.CommunityResource, NES.HiLo.Security" verb="*" path="*.txt" type="NES.HiLo.Security.CommunityResource, NES.HiLo.Security" />
</handlers>
</system.webServer>
<httpHandlers>
<add verb="*" path="*.txt" type="NES.HiLo.Security.CommunityResource, NES.HiLo.Security" />
</httpHandlers>
When I m making requests for URL like
http://local.mysite.com/media/CLT/ResourceUploads/1000277/Test1.txt
the handler never kicks in, the control never comes inside the code in the handler.
Any ideas what I m missing? thanks
According to the MSDN example of registering handler in IIS 7.0 in classic mode, you are missing a couple of attributes:
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<handlers>
<add name="CommunityResourceHandler" verb="*" path="*.txt"
type="NES.HiLo.Security.CommunityResource, NES.HiLo.Security"
modules="IsapiModule"
scriptProcessor="FrameworkPath\aspnet_isapi.dll"
resourceType="File" />
</handlers>
</system.webServer>
<httpHandlers>
<add verb="*" path="*.txt" type="NES.HiLo.Security.CommunityResource, NES.HiLo.Security" />
</httpHandlers>
I am developing an ASP.NET MVC applications with MS Visual Studio 2008 SP1.
My project structure is the default one:
Project |-Content |-css |-img |-Models |-Views
|-Controllers
The thing is, I am able to access all the content placed under Content directory provided the file is included in the project. On the other hand, if I happen to have an image (I.E. an image uploaded by the user) that's on the right physical directory (Project\Content\img) but is not included in the project, I keep getting a 404 error when I access them with a browser.
I think my URL is correct:
http://localhost:1260/Content/img/my_image.jpg
And I do have a file under Project\Content\img\my_image.jpg.
What can be wrong? Am I forced to include all the files on the project? I don't think so, because that would mean that I can't have images uploaded and saved by the web users this way.
Thanks a lot.
If you're hosting your project with IIS 7, you must add he content-type in IIS 7(Handler Mapping). But if you're hosting your project with the Asp.net Developer Server, it's not required.
Using the following code in web.config file
<configuration>
<system.webServer>
<handlers>
<add name="css mapping" path="*.css" verb="*" type="System.Web.StaticFileHandler" resourceType="Unspecified" preCondition="integratedMode" />
<add name="js mapping" path="*.js" verb="*" type="System.Web.StaticFileHandler" resourceType="Unspecified" preCondition="integratedMode" />
<add name="gif mapping" path="*.gif" verb="*" type="System.Web.StaticFileHandler" resourceType="Unspecified" preCondition="integratedMode" />
<add name="jpg mapping" path="*.jpg" verb="*" type="System.Web.StaticFileHandler" resourceType="Unspecified" preCondition="integratedMode" />
<add name="png mapping" path="*.png" verb="*" type="System.Web.StaticFileHandler" resourceType="Unspecified" preCondition="integratedMode" />
</handlers>
</system.webServer>
</configuration>