My api client code sends an authentication token to the request string:
www.example.com/api/user/get/123?auth_token=ABC123
I am using the Mvc Web api controller, and I have a filter that checks if auth_token is valid or not, but I'm not sure how to access the querystring request values.
This is what I am doing now, but it is clearly wrong:
Below the snippet is inside my filter, which inherits from:
ActionFilterAttribute
public override void OnActionExecuting(System.Web.Http.Controllers.HttpActionContext actionContext) { base.OnActionExecuting(actionContext); if (actionContext.Request.Properties.ContainsKey("auth_token") && actionContext.Request.Properties["auth_token"].ToString() == "ABC123") { ... } }
c # asp.net-mvc asp.net-web-api
loyalflow
source share