c# - Async methods causing 404 errors in app start -
I am using async
methods in my global.asax file, and one of the issues I am experiencing.
Even though should work with async
methods, when I set them to fire in Application_Start ()
, I get 404 errors until my App does not start, it has to be done when it should not be completed.
This is the code in my global. Essex:
Public class MvcApplication: System.Web.HttpApplication {protected Async zero applications_start () {var Init = new Init (); Awaiting Init.LoadAsync (); AreaRegistration.RegisterAllAreas (); FilterConfig.RegisterGlobalFilters (GlobalFilters.Filters); RouteConfig.RegisterRoutes (RouteTable.Routes); }}
Since I'm thinking application_start ()
wait
command, app When starting, the Application_Start ()
function is not being waiting for itself, so invoke the method without creating the application_start ()
function or Application_Start () another way
> a async
method (the latter will be given preference).
ASP AISNC is not allowed for Application_Start. However, you can use async for BeginRequest using HttpApplication.AddOnBeginRequestAsync (BeginEventHandler, EndEventHandler)
. There is a flag to indicate whether your Init.LoadAynync has been called so that you can trigger initialization only on the first request.
Then set the initial module for the application to create that first request.
Comments
Post a Comment