c# - Unable to cast HttpRequestMessage.Properties["MS_RequestContext"] as OwinHttpRequestContext at build time but valid at runtime -


i'm trying manually fiddle property of ms_requestcontext during controller activation inside webapi's compositionroot.

my create method receives system.net.http.httprequestmessage argument.

i can drill down request grab

 request.properties["ms_requestcontext"] 

properties dictionary<string,object> object owinhttprequestcontext @ runtime.

but whenever attempt cast, can access properties on requestcontext, nasty-gram visual studio

 (request.properties["ms_requestcontext"] owinhttprequestcontext).request.properties; 

the error comes is:

 type or namespace 'owinhttprequestcontext' not found (are missing using directive or assembly reference?) 

owinhttprequestcontext lives inside system.web.http.owin namespace. references set up. have added using statement measure.

so crazy part if roll code attempts directly reference request.properties, instead set breakpoint inside create method, can -through watch- execute

 (request.properties["ms_requestcontext"] system.web.http.owin.owinhttprequestcontext).request.properties 

without issue. can confirm have no problem modifying properties @ runtime through immediate window.

(request.properties["ms_requestcontext"] system.web.http.owin.owinhttprequestcontext).request.properties.add("foo","bar")

and property "foo" available of messagehandlers.

why not able perform same cast @ build time?


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -