c# - Razor View Race Condition -


in custom razor engine, derived razorviewengine, i've spotted think unstable code:

    public override viewengineresult findview(controllercontext controllercontext, string viewname, string mastername, bool usecache)     {         viewlocationformats = addviewdynamicformat(controllercontext, viewname).toarray();         areaviewlocationformats = addareaviewdynamicformat(controllercontext, viewname).toarray();         return base.findview(controllercontext, viewname, mastername, usecache);     } 

my concern when 2 requests being processed "at same time," first set location formats needs, before can use them - second threaded request might have chance set location formats different way. rest gets ugly.

is valid concern? said differently, asp.net mvc guarantee razor view engine handle 1 request @ time? doubt case.

likewise, if there 1 razor view engine object per request, ok. don't believe case.

update have confirmed race condition. have found article showing dynamic expansive razor search example, solves problem without race condition (though still wonder if has caching issue).

i'm positive razorviewengine isn't meant modified @ run-time, merely configured in global.asax application_start. believe razorviewengine instance exists life of app domain after startup.

if need add additional viewlocationformats or areaviewlocationformats in application_start. application_start guaranteed run once per app domain.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -