asp.net-web-api2

Web API Custom Filter not firing

独自空忆成欢 提交于 2020-08-07 17:59:29
问题 I have created a custom Filter Attribute that will be doing some basic token validation. So I started by just adding a few lines to see with it works correctly but for some reason is it not working. Custom Filter Class /// <summary> /// Basic Token Based Authitication /// </summary> public class BasicTokenValidation : ActionFilterAttribute { /// <summary> /// Validate Token /// </summary> /// <param name="actionContext"></param> public override void OnActionExecuting(HttpActionContext

Web API Custom Filter not firing

一曲冷凌霜 提交于 2020-08-07 17:56:29
问题 I have created a custom Filter Attribute that will be doing some basic token validation. So I started by just adding a few lines to see with it works correctly but for some reason is it not working. Custom Filter Class /// <summary> /// Basic Token Based Authitication /// </summary> public class BasicTokenValidation : ActionFilterAttribute { /// <summary> /// Validate Token /// </summary> /// <param name="actionContext"></param> public override void OnActionExecuting(HttpActionContext

Web API Custom Filter not firing

非 Y 不嫁゛ 提交于 2020-08-07 17:55:53
问题 I have created a custom Filter Attribute that will be doing some basic token validation. So I started by just adding a few lines to see with it works correctly but for some reason is it not working. Custom Filter Class /// <summary> /// Basic Token Based Authitication /// </summary> public class BasicTokenValidation : ActionFilterAttribute { /// <summary> /// Validate Token /// </summary> /// <param name="actionContext"></param> public override void OnActionExecuting(HttpActionContext

Web API Custom Filter not firing

喜夏-厌秋 提交于 2020-08-07 17:55:44
问题 I have created a custom Filter Attribute that will be doing some basic token validation. So I started by just adding a few lines to see with it works correctly but for some reason is it not working. Custom Filter Class /// <summary> /// Basic Token Based Authitication /// </summary> public class BasicTokenValidation : ActionFilterAttribute { /// <summary> /// Validate Token /// </summary> /// <param name="actionContext"></param> public override void OnActionExecuting(HttpActionContext

WebAPI returns corrupted, incomplete file

穿精又带淫゛_ 提交于 2020-08-07 07:44:42
问题 I want to return an image from WebApi endpoint. This is my method: [System.Web.Http.HttpGet] public HttpResponseMessage GetAttachment(string id) { string dirPath = HttpContext.Current.Server.MapPath(Constants.ATTACHMENT_FOLDER); string path = string.Format($"{dirPath}\\{id}.jpg"); try { HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK); var stream = new FileStream(path, FileMode.Open, FileAccess.Read); var content = new StreamContent(stream); result.Content = content;

WebAPI returns corrupted, incomplete file

对着背影说爱祢 提交于 2020-08-07 07:44:09
问题 I want to return an image from WebApi endpoint. This is my method: [System.Web.Http.HttpGet] public HttpResponseMessage GetAttachment(string id) { string dirPath = HttpContext.Current.Server.MapPath(Constants.ATTACHMENT_FOLDER); string path = string.Format($"{dirPath}\\{id}.jpg"); try { HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK); var stream = new FileStream(path, FileMode.Open, FileAccess.Read); var content = new StreamContent(stream); result.Content = content;

Get expire time of OAuth session

∥☆過路亽.° 提交于 2020-08-04 03:53:21
问题 To grant or revoke access to my webapis, I use OAuth password- and tokenrefreshworkflow. If I understand everything correctly the workflow should be something like this: Authenticate with username / password / client id Retrieve accestoken, refreshtoken and expire date Start timeout in client to refresh your token after expired token time Go on with bullet 2 -> and so on.. The progress above works fine so far. My problem is, that I don't get the expire time out of the users principle after

Identity Framework User Lockdown

╄→尐↘猪︶ㄣ 提交于 2020-07-21 03:55:26
问题 I'm trying to lock user login after 3 unsuccessful login attempts for 5 minutes. I have add this 3 lines to App_Start/IdentityConfig.cs public static ApplicationUserManager Create( ... ) method: manager.MaxFailedAccessAttemptsBeforeLockout = 3; manager.DefaultAccountLockoutTimeSpan = new TimeSpan(0, 5, 0); manager.UserLockoutEnabledByDefault = true; After that I register new user via POST /api/Account/Register (in default scaffolded AccountController ). Account is created and LockoutEnabled

Identity Framework User Lockdown

不想你离开。 提交于 2020-07-21 03:54:05
问题 I'm trying to lock user login after 3 unsuccessful login attempts for 5 minutes. I have add this 3 lines to App_Start/IdentityConfig.cs public static ApplicationUserManager Create( ... ) method: manager.MaxFailedAccessAttemptsBeforeLockout = 3; manager.DefaultAccountLockoutTimeSpan = new TimeSpan(0, 5, 0); manager.UserLockoutEnabledByDefault = true; After that I register new user via POST /api/Account/Register (in default scaffolded AccountController ). Account is created and LockoutEnabled

Authenticating against Microsoft Graph with SPA and then using token in Web API

筅森魡賤 提交于 2020-07-07 11:41:04
问题 I have an SPA that authenticates a user, by using msal.js, against an app registrered at the Application Registration Portal. It successfully retrieves a token and everything is fine so far. Then I have a ASP.NET Web API setup that should use the token from the SPA to make requests to Microsoft Graph on behalf of the user and this is where I run into trouble. So far I've set up a OWIN middleware on the API that should validate the token before making a request to the graph but no matter what