[整理]IIS 6.0 下部署 Asp.net MVC Web Api 后 HTTP PUT and DELETE 请求失败

时间:2022-06-16 06:31:46

http://guodong.me/?p=1560

ASP.NET MVC 4 has a new feature called WebAPI which makes it much easier to create a REST API in ASP.NET. Unfortunately, I ran into one problem with IIS 6.0 that prevented the full REST spec from being used. By default IIS 6 wouldn’t allow the PUT or DELETE verbs to be used with the WebAPI app that we created.

 

Page requests using GET and POST worked fine, but PUT and DELETE gave the following error:

Failed to load resource: the server responded with a status of 501 (Not Implemented)

In order to solve the issue I needed to add the ASP.NET 4.0 dll to
the Wildcard mappings in the Configuration area on the Home Directory
tab for the website. That fixed the problem for me. Here are the steps
that I took to correct the issue in IIS.

1. Find the web site in the “Web Sites” folder in Internet Information Services (IIS) and right-click and select properties.

[整理]IIS 6.0 下部署 Asp.net MVC Web Api 后 HTTP PUT and DELETE 请求失败

2. Go to the “Home Directory” tab and click the “Configuration…” button.

[整理]IIS 6.0 下部署 Asp.net MVC Web Api 后 HTTP PUT and DELETE 请求失败

3. Find the .aspx extension in the “Application extensions” table, select it and press the “Edit…” button.

[整理]IIS 6.0 下部署 Asp.net MVC Web Api 后 HTTP PUT and DELETE 请求失败

4. Copy the entire path and file name in the “Executable:” text box to the clipboard.  Press the “Cancel” button.

[整理]IIS 6.0 下部署 Asp.net MVC Web Api 后 HTTP PUT and DELETE 请求失败

5. Press the “Insert…” button near the “Wildcard application maps”
list box.  Paste the text from the clipboard into the “Executable:” text
box and press “OK”.

[整理]IIS 6.0 下部署 Asp.net MVC Web Api 后 HTTP PUT and DELETE 请求失败

6. Press OK on the Application Configuration dialog and again on the website properties box.

参考:

IIS WebDAV安全配置

http://*.com/questions/9904897/iisnode-iis7-5-405-method-not-allowed-when-performing-put-request

http://www.cnblogs.com/artech/p/3606873.html

http://www.cnblogs.com/artech/p/web-api-sample.html

http://blog.csdn.net/forgotaboutgirl/article/details/6936982