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:
This is how the Global.cs file looks.
There has to be a pony in this pile of s*%t somewhere.
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:
<%@ Application Codebehind="Global.asax.cs" inherits="Global" Language="C#" %>
Code:
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>());
AreaRegistration.RegisterAllAreas();
GlobalConfiguration.Configure(WebApiConfig.Register);
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
}
There has to be a pony in this pile of s*%t somewhere.