I have an existing MVC project which has a knockout front end and a WebAPI back end.
Due to a change in requirements I had to remove all the back end files from the project, leaving only the front end files.
Now I need to a WebAPI controller back into the project.
In order to configure the WebAPI I need to find an entry point into the C# code to trigger the configuration methods.
My understanding is that if the project has a Global.asax file, the Application_Start()
will automatically be fired on start up. And also if I have a startup.cs file with an owinStartup
property, this will also be triggered by default.
So I copied both these files from another project and edited as required, but neither files are being triggered on startup.
I assume I am missing some kind of configuration, but am not sure what?
Here is my startup.cs file:
using System.Web.Http;
using Microsoft.Owin;
using Newtonsoft.Json;
using Owin;
[assembly: OwinStartup(typeof(ClearviewLocal_ONFrontEnd_Rest.Startup))]
namespace ClearviewLocal_ONFrontEnd_Rest
{
/// <summary>
/// Application startup
/// </summary>
public class Startup
{
/// <summary>
/// Configure app
/// </summary>
/// <param name="app">Owin AppBuilder</param>
public void Configuration(IAppBuilder app)
{
var config = new HttpConfiguration(); //breakpoint here that is not being hit
}
}
}
and here is the Global.asax file:
using System;
using System.Web;
using System.Web.Http;
namespace ClearviewLocal_ONFrontEnd_Rest
{
/// <summary>
///
/// </summary>
public class WebApiApplication : HttpApplication
{
/// <summary>
///
/// </summary>
protected void Application_Start()
{
var config = new HttpConfiguration(); //Breakpoint here
}
}
}
I have looked at the answer to this question: OwinStartup not Starting ... Why? but this code was never in the Web.Config
Also, I have not removed any references from the project