asp.net-web-api

tokenClient.RequestAuthorizationCodeTokenAsync is clearing out HttpContext, can this be prevented?

笑着哭i 提交于 2021-02-11 12:22:09
问题 I have the following code: using IdentityModel.Client; using Microsoft.AspNet.Identity; var tokenClient = new HttpClient(); var testUserName = System.Web.HttpContext.Current.User.Identity.GetUserName(); // This returns a value var tokenResult = await tokenClient.RequestAuthorizationCodeTokenAsync( new AuthorizationCodeTokenRequest { Address = address, Code = authorizationCode, ClientId = clientId, ClientSecret = clientSecret, GrantType = "authorization_code", RedirectUri = redirectUri });

how to use usermanager on a blazor page?

五迷三道 提交于 2021-02-11 07:01:29
问题 hello community I have a question how can I use usermanager in a blazor page webassembly ? by injecting this: @inject UserManager<ApplicationUser> UserManager; I get the indication that a usage directive is missing as the class the ApplicationUser class is on the server and the client does not have access to the server. this is my code in blazor page: @page "/index" @inject AuthenticationStateProvider AuthenticationStateProvider @using Microsoft.AspNetCore.Identity; @inject UserManager

how to use usermanager on a blazor page?

夙愿已清 提交于 2021-02-11 07:00:30
问题 hello community I have a question how can I use usermanager in a blazor page webassembly ? by injecting this: @inject UserManager<ApplicationUser> UserManager; I get the indication that a usage directive is missing as the class the ApplicationUser class is on the server and the client does not have access to the server. this is my code in blazor page: @page "/index" @inject AuthenticationStateProvider AuthenticationStateProvider @using Microsoft.AspNetCore.Identity; @inject UserManager

Web API change JSON parser

独自空忆成欢 提交于 2021-02-11 00:12:03
问题 I am trying to change the JSON parser in my web API project. I have followed the following tutorials: https://docs.microsoft.com/en-us/aspnet/core/web-api/advanced/custom-formatters?view=aspnetcore-2.2 https://www.youtube.com/watch?v=tNzgXjqqIjI https://weblog.west-wind.com/posts/2012/Mar/09/Using-an-alternate-JSON-Serializer-in-ASPNET-Web-API I now have the following code: public class MyJsonFormatter : MediaTypeFormatter { public MyJsonFormatter() { base.SupportedMediaTypes.Add(new

Web API change JSON parser

て烟熏妆下的殇ゞ 提交于 2021-02-11 00:10:37
问题 I am trying to change the JSON parser in my web API project. I have followed the following tutorials: https://docs.microsoft.com/en-us/aspnet/core/web-api/advanced/custom-formatters?view=aspnetcore-2.2 https://www.youtube.com/watch?v=tNzgXjqqIjI https://weblog.west-wind.com/posts/2012/Mar/09/Using-an-alternate-JSON-Serializer-in-ASPNET-Web-API I now have the following code: public class MyJsonFormatter : MediaTypeFormatter { public MyJsonFormatter() { base.SupportedMediaTypes.Add(new

Web API change JSON parser

人盡茶涼 提交于 2021-02-11 00:09:54
问题 I am trying to change the JSON parser in my web API project. I have followed the following tutorials: https://docs.microsoft.com/en-us/aspnet/core/web-api/advanced/custom-formatters?view=aspnetcore-2.2 https://www.youtube.com/watch?v=tNzgXjqqIjI https://weblog.west-wind.com/posts/2012/Mar/09/Using-an-alternate-JSON-Serializer-in-ASPNET-Web-API I now have the following code: public class MyJsonFormatter : MediaTypeFormatter { public MyJsonFormatter() { base.SupportedMediaTypes.Add(new

Web API change JSON parser

不问归期 提交于 2021-02-11 00:09:15
问题 I am trying to change the JSON parser in my web API project. I have followed the following tutorials: https://docs.microsoft.com/en-us/aspnet/core/web-api/advanced/custom-formatters?view=aspnetcore-2.2 https://www.youtube.com/watch?v=tNzgXjqqIjI https://weblog.west-wind.com/posts/2012/Mar/09/Using-an-alternate-JSON-Serializer-in-ASPNET-Web-API I now have the following code: public class MyJsonFormatter : MediaTypeFormatter { public MyJsonFormatter() { base.SupportedMediaTypes.Add(new

Model null when use Route attribute

[亡魂溺海] 提交于 2021-02-10 20:18:23
问题 In my WebAPI I have model public class ListRequest { public int Skip { get; set; } = 0; public int Take { get; set; } = 30; } My action is [HttpGet] [Route("api/users")] public IHttpActionResult Get([FromUri] ListRequest request) { ... } I need to have possibility to not pass any query parameters, then default values should be used. But, when I go to http://localhost:44514/api/users the request is null. If I remove [Route("api/users")] then request is not null and has default values for

Custom Policy-Based Authorization in ASP.NET Framework

时光毁灭记忆、已成空白 提交于 2021-02-10 17:21:31
问题 I'm using ASP.NET API with .NET Framework 4.7.1 And I'm looking for custom policy-based authorization. This document described custom policy-based authorization for .NET core, but how could I implement it for .NET framework? 回答1: There is a Nuget package that backports the Policy-based authorization to .NET Framework 4. You can use Microsoft.Owin.Security.Authorization.Mvc or Microsoft.Owin.Security.Authorization.WebApi package, depending on what you need. Both packages will bring you the

Custom Policy-Based Authorization in ASP.NET Framework

谁说胖子不能爱 提交于 2021-02-10 17:04:26
问题 I'm using ASP.NET API with .NET Framework 4.7.1 And I'm looking for custom policy-based authorization. This document described custom policy-based authorization for .NET core, but how could I implement it for .NET framework? 回答1: There is a Nuget package that backports the Policy-based authorization to .NET Framework 4. You can use Microsoft.Owin.Security.Authorization.Mvc or Microsoft.Owin.Security.Authorization.WebApi package, depending on what you need. Both packages will bring you the