I'm using async
methods in my global.asax file, and am experiencing a problem.
Even though the async
methods are working as they should, when I fire them in Application_Start()
I get 404 errors when my app starts, until it's done, when it shouldn't complete until it's done.
Here's the code in my global.asax:
public class MvcApplication : System.Web.HttpApplication
{
protected async void Application_Start()
{
var Init = new Init();
await Init.LoadAsync();
AreaRegistration.RegisterAllAreas();
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
}
}
I'm thinking since Application_Start()
had to be made async
to allow an await
command, the Application_Start()
function itself is not being awaited when the app starts. Therefore, it's necessary to find out either how to await
the Application_Start()
function or another way to fire the method without having to make Application_Start()
an async
method (The latter would be preferred).