मेरे उत्पादन कोड में हमें एक समस्या है जहां Request.GetOwinContext() हमेशा शून्य देता है।एएसपी.Net वेबएपी ओविन: अनुरोध क्यों होगा। GetOwinContext() वापस शून्य?
मैं सेटअप एक छोटे से परीक्षण वेबएपीआई नियंत्रक कोशिश करते हैं और समस्या को अलग करने की:
public class TestController : ApiController
{
[HttpGet]
public async Task<IHttpActionResult> GetAsyncContext(string provider)
{
if (HttpContext.Current.GetOwinContext() == null)
return this.BadRequest("No HttpContext.Current Owin Context");
if (Request.GetOwinContext() == null)
return this.BadRequest("No Owin Context");
return this.Ok();
}
[HttpGet]
public IHttpActionResult GetContext(string provider)
{
if (HttpContext.Current.GetOwinContext() == null)
return this.BadRequest("No HttpContext.Current Owin Context");
if (Request.GetOwinContext() == null)
return this.BadRequest("No Owin Context");
return this.Ok();
}
}
पहले तो मैंने सोचा कि यह अतुल्यकालिक रूप से चल रहा है कार्रवाई विधि, लेकिन उसके बाद से ऊपर चल रहा है के साथ कुछ हो सकता है, यह बदल जाता है बाहर दोनों संस्करणों में, Request.GetOwinContext() शून्य देता है।
मैं माइक्रोसॉफ्ट.एस्पनेट.एबएपीआई.ऑविन.5.1.1 का उपयोग कर रहा हूं (जहां ऐसा लगता है कि GetOwinContext() एक्सटेंशन विधि परिभाषित है)।
यहां क्या हो रहा है पर कोई विचार ???
क्या आप निश्चित हैं कि स्टार्टअप क्लास को बुलाया जा रहा है और सभी मॉड्यूल पंजीकृत किए जा रहे हैं? – William