Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't make WebAPI application work on windows 2008 server

I'm new to Web API Applications. I created my very first application with only one simple Controller with only one Get() method that returns a List. In my PC it works fine. Even after I publish the solution and access it via my IIS 7.5, the results are ok: I access

http://localhost/Application/api/Controller 

and I get the answer I expect.

So I moved forward to the next step: deploying it to another server so other people in my office can access it. The server we use runs a Windows 2008 server. What I did was to simply copy the Publish folder generated by the publish command in Visual Studio 2012, and paste it in the inetpub\wwwroot folder in the server computer. Then, I accessed the IIS 7.5 that's running on the server and created a new application using the .NET 4.0 Application Pool, using the Publish folder as its physical path (exact same steps I did in my PC to publish it to my IIS).

The problem: when I try to access the application in the server machine (that's running windows 2008 server), I get the 404 error. It seems like it tries to find a physical path Application\api\Controller, insted of resolving it logically like my machine does.

I did try all the different solutions I found in the web:

  • I did enable all verbs in the ExtensionlessUrl-Integrated-4.0 under the mappings configuration for the Application in the IIS.
  • I did add the WebApiConfig.Register(GlobalConfiguration.Configuration); in my global asax.

What I noticed is that my machine has the .NET Framework 4.5 installed and the server machine only has the 4.0 framework (client and extended). But I get the same error even after compiling the application targetting the 4.0 framework.

The only MVC .dll I have in my bin directory is the System.Web.Mvc.dll... do I need any other DLL?

Thanks in advance.

like image 922
Piscies Avatar asked Dec 26 '12 13:12

Piscies


People also ask

How do I access IIS in Windows Server 2008?

Under the Web Server (IIS) node, select Internet Information Services (IIS) Manager, expand the name of the Web server, and then expand Sites. Right-click Default Web Site, and then click Start. If you need a secure Internet connection, set up Secure Sockets Layer (SSL).

Can Web API be hosted in Windows Service?

It means you can host a Web API in console application or windows service or OWIN or any other process that is managed by . NET framework. You need to do following steps in order to self-host a web API. Let's see how to host a simple Web API in console application.


1 Answers

Try this:

<system.webServer>
    .....
    <modules runAllManagedModulesForAllRequests="true" />
    .....
</system.webServer>
like image 72
tonymayoral Avatar answered Sep 18 '22 02:09

tonymayoral