Click here to Skip to main content
15,907,492 members
Home / Discussions / C#
   

C#

 
GeneralRe: NEW to c# Pin
Ravi Bhavnani16-Jul-15 2:27
professionalRavi Bhavnani16-Jul-15 2:27 
GeneralRe: NEW to c# Pin
jamesmc153516-Jul-15 2:37
jamesmc153516-Jul-15 2:37 
AnswerRe: NEW to c# Pin
OneWinsto20-Jul-15 11:11
OneWinsto20-Jul-15 11:11 
GeneralRe: NEW to c# Pin
jamesmc153520-Jul-15 21:36
jamesmc153520-Jul-15 21:36 
QuestionHow do i post headers and XML body to webservice Pin
kundan sakpal13-Jul-15 23:40
kundan sakpal13-Jul-15 23:40 
QuestionRe: How do i post headers and XML body to webservice Pin
Richard MacCutchan13-Jul-15 23:44
mveRichard MacCutchan13-Jul-15 23:44 
QuestionWhy is my Sidebar not in the right place?? Pin
blacktech13-Jul-15 8:51
blacktech13-Jul-15 8:51 
AnswerRe: Why is my Sidebar not in the right place?? Pin
blacktech13-Jul-15 8:53
blacktech13-Jul-15 8:53 
SuggestionRe: Why is my Sidebar not in the right place?? Pin
Richard MacCutchan13-Jul-15 22:15
mveRichard MacCutchan13-Jul-15 22:15 
GeneralRe: Why is my Sidebar not in the right place?? Pin
blacktech15-Jul-15 2:39
blacktech15-Jul-15 2:39 
QuestionSaving an array to disk Pin
Member 1171394212-Jul-15 5:57
Member 1171394212-Jul-15 5:57 
AnswerRe: Saving an array to disk PinPopular
OriginalGriff12-Jul-15 5:59
mveOriginalGriff12-Jul-15 5:59 
GeneralRe: Saving an array to disk Pin
Member 1171394212-Jul-15 6:05
Member 1171394212-Jul-15 6:05 
QuestionHow to update database when adding an item Pin
Member 1183153312-Jul-15 5:15
Member 1183153312-Jul-15 5:15 
AnswerRe: How to update database when adding an item Pin
OriginalGriff12-Jul-15 5:46
mveOriginalGriff12-Jul-15 5:46 
GeneralRe: How to update database when adding an item Pin
Member 1183153312-Jul-15 5:53
Member 1183153312-Jul-15 5:53 
AnswerRe: How to update database when adding an item Pin
Dave Kreskowiak12-Jul-15 6:26
mveDave Kreskowiak12-Jul-15 6:26 
GeneralRe: How to update database when adding an item Pin
Member 1183153312-Jul-15 7:00
Member 1183153312-Jul-15 7:00 
QuestionLinq-ToSql and EF Questions Pin
Kevin Marois10-Jul-15 4:54
professionalKevin Marois10-Jul-15 4:54 
AnswerRe: Linq-ToSql and EF Questions Pin
Richard Deeming10-Jul-15 5:54
mveRichard Deeming10-Jul-15 5:54 
GeneralRe: Linq-ToSql and EF Questions Pin
Kevin Marois10-Jul-15 5:56
professionalKevin Marois10-Jul-15 5:56 
Questionwifi form Pin
Member 118239158-Jul-15 16:51
Member 118239158-Jul-15 16:51 
AnswerRe: wifi form Pin
Dave Kreskowiak8-Jul-15 17:22
mveDave Kreskowiak8-Jul-15 17:22 
QuestionCasting HttpRequestMessage.Properties["MS_RequestContext"] to OwinHttpRequestContext Pin
Alaric_8-Jul-15 11:09
professionalAlaric_8-Jul-15 11:09 
So this is weird.
I'm trying to manually fiddle with a property of my MS_RequestContext during Controller Activation inside my WebApi's CompositionRoot.


my Create method receives a System.Net.Http.HttpRequestMessage argument.

I can drill down request to grab
C#
request.Properties["MS_RequestContext"]

Properties is a
dictionary<string,object>
That object will be an OwinHttpRequestContext at runtime.

But whenever I attempt to cast, so that I can access the properties on the RequestContext, I get a naughty-gram from Visual Studio
C#
(request.Properties["MS_RequestContext"] as OwinHttpRequestContext).Request.Properties;


The error that comes back is:
C#
The type or namespace 'OwinHttpRequestContext' could not be found (are you missing a using directive or an assembly reference?)


Well...OwinHttpRequestContext lives inside the System.Web.Http.Owin namespace. My references are all set up. I even have added a using statement for good measure.

So the crazy part is that if I remove my code that attempts to directly reference request.Properties, but instead set a breakpoint inside my Create method, I can -through a watch- execute

(request.Properties["MS_RequestContext"] as System.Web.Http.Owin.OwinHttpRequestContext).Request.Properties

without issue. I can confirm that I have no problem modifying the properties at runtime through the immediate window.

Why am I not able to perform this same cast at build time?

I've inspected the
HttpContext.Current.GetOwinContext()

for access to the property that I need to manipulate, but it's not available on IOwinContext.
"I need build Skynet. Plz send code"

QuestionSelectSingleNode issue Pin
tiwal7-Jul-15 7:42
tiwal7-Jul-15 7:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.