Using WebApi on WinHost

Discussion in 'Site Programming, Development and Design' started by daveharney, Jan 21, 2014.

  1. I've put together a very basic tutorial for a jQuery Mobile app with a very basic tutorial using the Web Api with VS 2013 and VB.NET. The Web Api is just for use with my UI within my app as a way to bridge between html and It works perfectly on my development machine but the Web Api part fails when I move it to Winhost. Do I need to change one of the config files or does Winhost have to do something to allow Web Api?

    Here is the html/JS/jQuery code that calls the code:
     var uri = 'api/class1s';  // sets up the URI
            function find() {
                var id = $('#prodId').val();
                $.getJSON(uri + '/' + id)              //  calls the URI with a search id provided below
                    .done(function (data) {
                    .fail(function (jqXHR, textStatus, err) {
                        $('#product').text('Error: ' + err);
    There is an input field to provide the id used in the $.getJSON above
                    <input type="text" id="prodId" size="5" />
                    <input type="button" value="Search" onclick="find();" />
                    <p id="product" />
    The web.config is:
        <compilation debug="true" targetFramework="4.5.1" />
        <httpRuntime targetFramework="4.5.1" />
          <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"       preCondition="integratedMode,runtimeVersionv4.0" />
    There is also a WebApiConfig:
         Imports System
        Imports System.Collections.Generic
        Imports System.Linq
        Imports System.Web.Http
        Public Module WebApiConfig
        Public Sub Register(ByVal config As HttpConfiguration)
            ' Web API configuration and services
            ' Web API routes
                defaults:=New With {.id = RouteParameter.Optional}
         End Sub
        End Module
    There is also a class to define the data and a "controller" to populate data and return data via the Web Api. These should not affect this problem (and work perfectly on my desktop PC). Otherwise, this is just a standard VS2013 ASP.Net 4.5.1 project using an empty website with the Web Api option selected. Is there a config change needed in my code or does Winhost have to do something to enable Web Api?
    Last edited by a moderator: Oct 14, 2015
  2. I should have known better! I was so focused on this having only html web pages that I forgot that the VB code behind was still ASP.NET. I forgot to configure the folder for asp. It works fine now.
    ComputerMan likes this.
  3. ComputerMan

    ComputerMan Winhost Staff

    Glad you resolved your problem :)

Share This Page