Archive

Posts Tagged ‘IIS’

“Method Not Found” in ASP.NET Web API when using PUT and DELETE Verbs

Now that you have deployed your REST API and you are receiving “Method Not Found” exception / 404 exceptions when using PUT and DELETE verbs, while GET and POST is working absolutely fine. The fix is simple and needs small changes within IIS.

Open “Internet Information Services (IIS) Manager”, select the corresponding application and double-click on the “Handler Mappings” as shown below:

Image

Then select the “ExtensionlessUrlHandler-Integrated-4.0″ handler and double-click to edit this managed handler and click on “Request Restrictions…” button, as highlighted below:

Image

In the “Verbs” tab, select “One of the following verbs:” option and type-in the following verbs, “GET, HEAD, POST, DEBUG, PUT, DELETE”. Note: By default the “All verbs” option is selected by default.

Image

One final step is to ensure that your “web.config” contains “PUT” and “DELETE” in the verb attribute for “ExtensionlessUrl-Integrated-4.0” under the <handlers> section within <system.webServer>. Do a Find (Ctrl + F) if you have a really huge entries in “web.config” file.

<system.webServer>
  <handlers>
    <add name="ExtensionlessUrl-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
  </handlers>
</system.webServer>

You are good to go! As a practice I always perform a “Restart”, under “Manage Web Site” within the “Internet Information Services (IIS) Manager” window.

Categories: ASP.NET, C# Tags: , , , , , , ,

IIS Server Variables

November 3, 2009 2 comments

IIS server variables provide information about the server, the connection with the client, and the current request on the connection.

IIS server variables are not the same as environment variables.

Paste the code given below in your asp.net web page [HTML Design] to see the information associated for each of the iis server variables.

<%Response.Write(HttpContext.Current.Request.ServerVariables["ALL_HTTP"]);%>
<%Response.Write(HttpContext.Current.Request.ServerVariables["ALL_RAW"]);%>
<%Response.Write(HttpContext.Current.Request.ServerVariables["APPL_MD_PATH"]);%>
<%Response.Write(HttpContext.Current.Request.ServerVariables["AUTH_TYPE"]);%>
<%Response.Write(HttpContext.Current.Request.ServerVariables["AUTH_PASSWORD"]);%>
<%Response.Write(HttpContext.Current.Request.ServerVariables["AUTH_USER"]);%>
<%Response.Write(HttpContext.Current.Request.ServerVariables["CERT_COOKIE"]);%>
<%Response.Write(HttpContext.Current.Request.ServerVariables["CERT_FLAGS"]);%>
<%Response.Write(HttpContext.Current.Request.ServerVariables["CERT_ISSUER"]);%>
<%Response.Write(HttpContext.Current.Request.ServerVariables["CERT_KEYSIZE"]);%>
<%Response.Write(HttpContext.Current.Request.ServerVariables["CERT_SECRETKEYSIZE"]);%>
<%Response.Write(HttpContext.Current.Request.ServerVariables["CERT_SERIALNUMBER"]); %>
<%Response.Write(HttpContext.Current.Request.ServerVariables["CERT_SERVER_ISSUER"]);%>
<%Response.Write(HttpContext.Current.Request.ServerVariables["CERT_SERVER_SUBJECT"]);%>
<%Response.Write(HttpContext.Current.Request.ServerVariables["CONTENT_LENGTH"]);%>
<%Response.Write(HttpContext.Current.Request.ServerVariables["CONTENT_TYPE"]);%>
<%Response.Write(HttpContext.Current.Request.ServerVariables["GATEWAY_INTERFACE"]);%>
<%Response.Write(HttpContext.Current.Request.ServerVariables["HTTPS"]);%>
<%Response.Write(HttpContext.Current.Request.ServerVariables["HTTPS_KEYSIZE"]);%>
<%Response.Write(HttpContext.Current.Request.ServerVariables["HTTPS_SECRETKEYSIZE"]);%>
<%Response.Write(HttpContext.Current.Request.ServerVariables["HTTPS_SERVER_ISSUER"]);%>
<%Response.Write(HttpContext.Current.Request.ServerVariables["HTTPS_SERVER_SUBJECT"]);%>
<%Response.Write(HttpContext.Current.Request.ServerVariables["INSTANCE_ID"]);%>
<%Response.Write(HttpContext.Current.Request.ServerVariables["INSTANCE_META_PATH"]);%>
<%Response.Write(HttpContext.Current.Request.ServerVariables["LOCAL_ADDR"]);%>
<%Response.Write(HttpContext.Current.Request.ServerVariables["LOGON_USER"]);%>
<%Response.Write(HttpContext.Current.Request.ServerVariables["PATH_INFO"]);%>
<%Response.Write(HttpContext.Current.Request.ServerVariables["PATH_TRANSLATED"]);%>
<%Response.Write(HttpContext.Current.Request.ServerVariables["QUERY_STRING"]);%>
<%Response.Write(HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"]);%>
<%Response.Write(HttpContext.Current.Request.ServerVariables["REMOTE_HOST"]);%>
<%Response.Write(HttpContext.Current.Request.ServerVariables["REQUEST_METHOD"]);%>
<%Response.Write(HttpContext.Current.Request.ServerVariables["SCRIPT_MAP"]);%>
<%Response.Write(HttpContext.Current.Request.ServerVariables["SCRIPT_NAME"]);%>
<%Response.Write(HttpContext.Current.Request.ServerVariables["SERVER_NAME"]);%>
<%Response.Write(HttpContext.Current.Request.ServerVariables["SERVER_PORT"]);%>
<%Response.Write(HttpContext.Current.Request.ServerVariables["SERVER_PORT_SECURE"]);%>
<%Response.Write(HttpContext.Current.Request.ServerVariables["SERVER_PROTOCOL"]);%>
<%Response.Write(HttpContext.Current.Request.ServerVariables["SERVER_SOFTWARE"]);%>
<%Response.Write(HttpContext.Current.Request.ServerVariables["URL"]);%>
<%Response.Write(HttpContext.Current.Request.ServerVariables["HTTP_ACCEPT"]);%>
<%Response.Write(HttpContext.Current.Request.ServerVariables["HTTP_ACCEPT_LANGUAGE"]);%>
<%Response.Write(HttpContext.Current.Request.ServerVariables["HTTP_CONNECTION"]);%>
<%Response.Write(HttpContext.Current.Request.ServerVariables["HTTP_HOST"]);%>
<%Response.Write(HttpContext.Current.Request.ServerVariables["HTTP_REFERER"]);%>
<%Response.Write(HttpContext.Current.Request.ServerVariables["HTTP_USER_AGENT"]);%>
<%Response.Write(HttpContext.Current.Request.ServerVariables["HTTP_COOKIE"]);%>
<%Response.Write(HttpContext.Current.Request.ServerVariables["HTTP_UA_CPU "]);%>
<%Response.Write(HttpContext.Current.Request.ServerVariables["HTTP_ACCEPT_ENCODING"]);%>

References: http://msdn.microsoft.com/en-us/library/ms524602.aspx

%d bloggers like this: