I have a code which registers the route in Application_AcquireRequestState event of the application. Once the routes are registered, I set a flag in the Http runtime cache so that I don't execute the route registration code again. There is a specific reason to register the route in this event Application_AcquireRequestState.
Once the app pool is restarted and if a valid(matching the route) request comes in, the route registration code kicks in but that request is not served by IIS/ASP.Net and it returns 404. The subsequent valid requests are all working fine.
I want to make sure even the first request is also served correctly.
Is it possible to rewrite the request so that after the route registration is done we can somehow try to replay the request if the url matches with one of the route that are registered? Is there any solution to solve this problem?
1 Answers
Answers 1
This is a kind of pseudocodewhich you can use in Global.asax.
private bool RootIsRegistered = false; //register Application level var void Application_BeginRequest(object sender,EventArgs e){ if(!RootIsRegistered) RegisterRoots(); } This way you can be sure that your roots are registered even at the first request.
0 comments:
Post a Comment