Quantcast
Channel: ASPNETWebStack Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 7215

Edited Issue: AuthorizeFilter dysfunction under async implementation [572]

$
0
0
Implement AuthorizeFilter as following:<br /><br /> public class TheAuthrizeAttribute : AuthorizationFilterAttribute<br /> {<br /> public async override void OnAuthorization(System.Web.Http.Controllers.HttpActionContext actionContext)<br /> {<br /> var db = new MockDB();<br /> bool pass = await db.AsyncValidate(actionContext.Request);<br /><br /> // validate;<br /> if (!pass)<br /> {<br /> actionContext.Response = new System.Net.Http.HttpResponseMessage(HttpStatusCode.Unauthorized);<br /> }<br /> }<br /> }<br /><br />The db.AsyncValidate return in 500 ms. However the work flow continues without waiting for its return and the Action with this AuthorizeAttribute ultimately been executed.

Viewing all articles
Browse latest Browse all 7215

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>