Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Web API Routing Not working in Web Site App.

Web API Routing Not working in Web Site App.

Web API Routing Not working in Web Site App.

I have developed an web application in Visual Studio 2013 which uses the development server that comes with VS.
I now want to port it to a Website to use IIS running on my PC.
I have had a thousand challenges to date, not the least of which is the Global.asax file which registers all the web API stuff.
In order for it to compile, I had to separate out the code behind to a class called 'Global' in the 'App_Code' folder and have Global.asax inherit from Global.
It all compiles happily now.

I have also put all my Web API controllers under the app_code folder as per various recommendations.

However, in debug mode at least, Application_Start never seems to run, so I can't be sure my web api stuff is being initialised.
in IE under developer tools, the first call to a web api controller falls over with a 404, and it think its a text/html call, not application/json. The call is a $.getJSON method.

Any help much appreciated.

This is how the Global.asax file look:

CODE --> C#

<%@ Application Codebehind="Global.asax.cs" inherits="Global" Language="C#" %> 
This is how the Global.cs file looks.

CODE --> C#

public class Global : System.Web.HttpApplication

		 public class WebApiApplication : System.Web.HttpApplication
        protected void Application_Start()
            //Database.SetInitializer(new DropCreateDatabaseIfModelChanges<GNC_CorpContext>());
            // LearnNow version with context added.
            Database.SetInitializer<Test_CACS_Data.Models.Test_CACS_DataContext>(new DropCreateDatabaseIfModelChanges<Test_CACS_DataContext>());

There has to be a pony in this pile of s*%t somewhere.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close