asp.net-core-3.0

ASP.NET MVC Core 3.0 API Serialize Enums to String

会有一股神秘感。 提交于 2020-03-18 04:28:07
问题 How to serialize Enum fields to String instead of an Int in ASP.NET MVC Core 3.0? I'm not able to do it the old way. services.AddMvc().AddJsonOptions(opts => { opts.JsonSerializerOptions.Converters.Add(new StringEnumConverter()); }) I'm getting an error: cannot convert from 'Newtonsoft.Json.Converters.StringEnumConverter' to 'System.Text.Json.Serialization.JsonConverter' 回答1: New System.Text.Json serialization ASP.NET MVC Core 3.0 uses built-in JSON serialization. Use System.Text.Json

ASP.Net Core exclude published language directories other than english

為{幸葍}努か 提交于 2020-03-04 23:06:32
问题 I publish my ASP.Net Core 3.1 Server like this: dotnet publish --configuration Release --runtime win7-x64 -p:PublishTrimmed=true --output c:\MyServer What I get in c:\MyServer is a lot of international language directories: cs, de, es, fr, zh-hans etc How can I publish with only the English version ? I tried using ExcludeFoldersFromDeployment in my csproj: <PropertyGroup> <TargetFramework>netcoreapp3.1</TargetFramework> <RuntimeIdentifier>win7-x64</RuntimeIdentifier>

Oauth2 with Postman and IdentityServer4

孤街醉人 提交于 2020-03-03 07:48:48
问题 This bounty has ended . Answers to this question are eligible for a +250 reputation bounty. Bounty grace period ends in 8 hours . Bastien Vandamme wants to draw more attention to this question: I need help on this one. Is there people fro Postman community that can help? I'm trying to register authenticate with Postman on my Identity Server 4. It worked with .Net Code 2 but I recently updated to .Net Core 3 and did adaptations. I can open my login page, I can login but then I'm not redirected

Oauth2 with Postman and IdentityServer4

纵然是瞬间 提交于 2020-03-03 07:48:11
问题 This bounty has ended . Answers to this question are eligible for a +250 reputation bounty. Bounty grace period ends in 8 hours . Bastien Vandamme wants to draw more attention to this question: I need help on this one. Is there people fro Postman community that can help? I'm trying to register authenticate with Postman on my Identity Server 4. It worked with .Net Code 2 but I recently updated to .Net Core 3 and did adaptations. I can open my login page, I can login but then I'm not redirected

Can't enable CORS for specific API controllers in ASP.NET Core WebApp targeting netcoreapp3.0

老子叫甜甜 提交于 2020-03-02 07:33:11
问题 I'm trying to enable CORS for a specific API controller in an ASP.NET Core application. First, I install the NuGet package, and this is added to my .csproj : <PackageReference Include="Microsoft.AspNetCore.Cors" Version="2.2.0" /> Then, I add the following in my ConfigureServices : services.AddCors(options => { options.AddPolicy("AllowAll", builder => builder.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader()); }); After that, if I add this in my Configure , it works: app.UseCors("AllowAll");

Creating a custom SignInManager in Asp.Net Core 3 Identity

霸气de小男生 提交于 2020-03-01 06:37:55
问题 I want to create a custom class for my SignInManager, so I've created a class that inherts from SignInManager<> as follows: public class ApplicationSignInManager : SignInManager<ApplicationUser> { private readonly UserManager<ApplicationUser> _userManager; private readonly ApplicationDbContext _dbContext; private readonly IHttpContextAccessor _contextAccessor; public ApplicationSignInManager( UserManager<ApplicationUser> userManager, IHttpContextAccessor contextAccessor,

Creating a custom SignInManager in Asp.Net Core 3 Identity

情到浓时终转凉″ 提交于 2020-03-01 06:37:29
问题 I want to create a custom class for my SignInManager, so I've created a class that inherts from SignInManager<> as follows: public class ApplicationSignInManager : SignInManager<ApplicationUser> { private readonly UserManager<ApplicationUser> _userManager; private readonly ApplicationDbContext _dbContext; private readonly IHttpContextAccessor _contextAccessor; public ApplicationSignInManager( UserManager<ApplicationUser> userManager, IHttpContextAccessor contextAccessor,

How do I use ASP.NET Core 3.0 types from a library project for shared Controllers, Middleware etc?

自闭症网瘾萝莉.ら 提交于 2020-02-26 07:11:25
问题 While ASP.NET Core up to 2.2 could be consumed through NuGet to create library projects for shared Controllers, Middleware etc, how do I create a library that is able to use ASP.NET Core 3.0 types? While for projects containing views there is a "Razor Class Library" ( razorclasslib ) template, how do I create a library that only contains logic components? 回答1: Applications built for .NET Core 3.0 can reference one or more shared frameworks. ASP.NET Core is one of these shared frameworks

How do I use ASP.NET Core 3.0 types from a library project for shared Controllers, Middleware etc?

痴心易碎 提交于 2020-02-26 07:09:28
问题 While ASP.NET Core up to 2.2 could be consumed through NuGet to create library projects for shared Controllers, Middleware etc, how do I create a library that is able to use ASP.NET Core 3.0 types? While for projects containing views there is a "Razor Class Library" ( razorclasslib ) template, how do I create a library that only contains logic components? 回答1: Applications built for .NET Core 3.0 can reference one or more shared frameworks. ASP.NET Core is one of these shared frameworks

Using nameof() with Url.Action() and async methods in ASP.NET Core 3.x MVC

给你一囗甜甜゛ 提交于 2020-02-25 01:52:07
问题 Let's say I have a ASP.NET Core 3.0 MVC application, which features a simple controller containing two actions and using attribute based routing: [Route("home")] public class HomeController : Controller { public static string ControllerName { get; } = "Home"; public HomeController() { } string GenerateUrls() { string url1 = Url.Action(nameof(Action1), ControllerName); string url2 = Url.Action(nameof(Action2Async), ControllerName); return $"Action1: '{url1}'\nAction2: '{url2}'"; } [HttpGet("a1