Click here to Skip to main content
15,884,298 members
Articles / Web Development / ASP.NET

Consuming and Deploying ASP.NET WebApi Services – Gotchas!!

Rate me:
Please Sign up or sign in to vote.
5.00/5 (4 votes)
31 Jul 2020CPOL3 min read 17.9K   6   2
Gotchas in consuming and deploying ASP.NET WebAPI services
In this post, you will read about some issues I encountered while developing using ASP.NET WebApi and the solutions to get around those issues.

Last week, I posted about how every web programmer should know about the RESTful nature of Web and start using ASP.NET MVC 4 Web API to accomplish the same. The post was accompanied by a sample HTTP GET resource call to an ASP.NET Web API controller action.

So, I believe you have already started using WebApi; if not, then this post may still help you as and when you start.

This post focuses on some of the issues I encountered while developing using ASP.NET WebApi and the solutions to get around those issues.

Gotcha 1 –> PUT and DELETE Request Won’t Work on Internet Explorer 10

This one caused quite a pain when I started using WebApi and discovered that PUT and DELETE request don’t work in Internet Explorer 10 (specifically in Windows 8 64-bit). I am not sure why it doesn’t work in the latest and greatest version of Internet Explorer, BUT that’s how it is. There is a workaround for this issue. We can add this tag inside the <head> tag of our Web page to make Internet Explorer 10 work like Internet Explorer 9.

XML
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE9" >

You could add it to all your pages or on just the pages which make PUT or DELETE requests, your call. BUT it is something to keep in mind while developing with ASP.NET WebApi until Microsoft comes up with a fix for this.

Gotcha 2 –> PUT and DELETE Requests Do NOT Work Once the Application is Deployed in IIS

When you start working with WebApi, you’ll realize it's awesome, very easy and all is honky dory as long as you are developing in VS and debugging your solution. BUT, once you deploy your WebApi application in IIS, you run into problems and some if your WebApi calls do not work. Don’t be surprised as this is quite a common issue as IIS is by default not configured to serve PUT/DELETE requests.

Configuring IIS 7.5 for WebApi

Sometimes, the WebDav module installed in IIS 7/7.5 causes issues when a WebApi application is deployed in IIS. Not sure what the reason is, BUT the solution that worked for me was removing the WebDav module for my application. This is made possible by adding the below tag in your web.config file, which instructs IIS to not register the WebDav module for our application. The below tags have to be included inside the <system.webServer> tag in the application’s web.config.

XML
<modules runAllManagedModulesForAllRequests="true">
<remove name="WebDAVModule" />
</modules>
<handlers>
<remove name="WebDAV" />
</handlers>

Configuring IIS 6 for WebApi

This one is a little tricky and has no proper explanation as to why it works. BUT we need to configure IIS6 for WebApi for our application to work consistently. The workaround has been sourced from Phil Haack’s post about using ASP.NET MVC on IIS 6. The post itself is very informative, BUT the part which we are interested in is at the bottom. So, I’m going to put it out here for you guys:

  • Right click on your deployed application and select properties.
  • In the properties windows, click Configuration to open the “Application Configuration” window.

    application mappings

  • Get the path to the aspnet_isapi DLL using the below method.

One easy way to find out is to find the .aspx extension in the list and double click it to bring up the mapping dialog.

extension mapping

Now, you can copy the path in the Executable text box to your clipboard.

  • Now, onto the previous “Application Configuration” window. In the Wildcard application maps section, click the Insert… button.
  • This brings up the wildcard application mapping dialog. Enter the path to the aspnet_isapi.dll copied in the previous step.

wildcard extension mapping

Don’t forget to uncheck the Verify that file exists checkbox! This is one of the most common mistakes people make and can cause a headache if not done. It may cause the application to stop working completely.

So, that’s it. You should be good to go. Remember, everybody might not face these issues as their IISs might be configured correctly or they might be using the correct version of the correct browser already. BUT having knowledge about these Gotchas should come in handy.

If you have any questions or view regarding these, give me a shout in the comments section.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
United States United States
I am a Developer working across multiple Technologies like .NET, Scala, Angular and NodeJS.
Passionate about WEB technologies more than anything.
Fascinated about the idea of how the WEB world and the WinForm world are slowly merging into each other, with a very thin line to differentiate them.

I am an active blogger and I blog mostly about Technology. Also, I have presented at certain points in the past on technical topics.

My Blog


Life & Tech

Programming Community Profiles


Stack Overflow
GitHub

Presentations


Slideshare

Social Profiles


Facebook | Twitter | LinkedIn | Google+

Comments and Discussions

 
PraiseMessage Closed Pin
1-Aug-20 2:52
Member 149043641-Aug-20 2:52 
SuggestionPUT and DELETE do work on Internet Explorer 10 Pin
Member 1019114028-Jul-16 7:08
Member 1019114028-Jul-16 7:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.