c# - When does HttpRequest get created? -


in mvc web application, i'm checking request.islocal see if application running on machine--if is, set global static variable tells rest of application in 'debug mode'.

the problem is, don't know when check.

i tried in global.asax.cs file, under application_start(), this:

protected void application_start() {     if (request.islocal)         isdebug = true;      arearegistration.registerallareas();     registerroutes(routetable.routes);     controllerbuilder.current.setcontrollerfactory(new ninjectcontrollerfactory()); } 

the trouble is, request object has not been initialized yet. httpexception says

the incoming request not match route

so, question when request object initialized, , there event of sort handle in order run check after request object ready?

application_start() fires when mvc site's app pool spun up. doesn't know "request" object. though correct place set application-wide, won't able request.islocal. you'll have use different stragegy. @jason's suggestion of using machine name option.

if you'd check request.islocal every request, write handler method application_beginrequest in global.asax. see this more info.


Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -