asp.net-core-3.1

Validating non-nullable property in Body as Required - AspNetCore 3.1

天涯浪子 提交于 2020-06-17 09:08:38
问题 I am trying to validate that if a property / field is completely left off on a request that the ModelState is invalid and a BadRequest is sent back to the client, however I am struggling with handling of non-nullable types in request bodies. Works for nullable types [Required] public string NullableString { get; set; } Works for non-nullable and nullable parameters public IActionResult RequiredNonNullableIntQueryString([Required]int nonNullableInt) public IActionResult

ASP.NET Core 3.1 How can I get the controller to use System.Text.Json to serialize and deserialize

喜你入骨 提交于 2020-05-28 08:05:45
问题 I am converting from .NET CORE 2.2 to 3.1. Is it possible to force the controller to use System.Text.Json to serialize and deserialize any incoming request and response? Basically, when the request comes in I want to use System.Text.Json and when a response goes out I want to use System.Text.Json . If yes, how? The reason for doing this is that Microsoft is really pushing this library as the replacement for Newtonsoft.Json as being so much safer and faster. But, I cannot seem to find any

ASP.NET Core 3.1 How can I get the controller to use System.Text.Json to serialize and deserialize

若如初见. 提交于 2020-05-28 08:05:34
问题 I am converting from .NET CORE 2.2 to 3.1. Is it possible to force the controller to use System.Text.Json to serialize and deserialize any incoming request and response? Basically, when the request comes in I want to use System.Text.Json and when a response goes out I want to use System.Text.Json . If yes, how? The reason for doing this is that Microsoft is really pushing this library as the replacement for Newtonsoft.Json as being so much safer and faster. But, I cannot seem to find any

Ember Octane when calling a save on the model what is the default accept and content-type headers?

亡梦爱人 提交于 2020-05-16 02:31:06
问题 In Ember Octane, when calling a save on the model, which calls a save to the back-end (.NET CORE 3.1), what is the default accept and content-type headers? I have tried looking online, but I cannot seem to find anything in the documentation. Is it application/json or application/vnd.api+json ? 回答1: It depends on the adapter you are using , the default one is json-api , the latest JSON API specification says Clients MUST send all JSON:API data in request documents with the header Content-Type:

HttpRequest.RouteValues property is not accessible from code but accessible from debugger

穿精又带淫゛_ 提交于 2020-05-14 20:00:12
问题 I am trying to create middleware which performs some checking for particular requests. For example, I have such routes: api/Test/{paramToCheck}/aaa api/Test/bbb/ccc and I have these requests: http://some-host-and-port/api/Test/1234/aaa http://some-host-and-port/api/Test/bbb/ccc Now inside my middleware I want to check if request contains {paramToCheck} and get value of this parameter. When I set breakpoint inside InvokeAsync I can see httpContext.Request.RouteValues property containing all

How do I install .NET Core in the Azure CLI shared folder?

╄→гoц情女王★ 提交于 2020-04-30 06:29:11
问题 I need to update the .NET Core version for use with Azure Functions. The dotnet command shows that the highest version available is 2.2.402. Checking in the Azure Portal CLI, the .NET Core files are installed in usr/share/dotnet/sdk . I can install .NET Core v3.1.0.2 on my Windows 10 PC, but I can't see how to install into the share/dotnet/sdk folder so that the global.json can reference this version of .NET Core. After installing .NET Core on Windows 10 on the c:\ drive: PS /home/username>

How to correctly resolve services to use in the ConfigureServices() in ASP.NET Core 3.1?

帅比萌擦擦* 提交于 2020-04-13 07:04:50
问题 I have an ASP.NET Core 3.1 based app. During the app startup, in the ConfigureServices(IServiceCollection services) I want to register my services. But during configuring services, I want to boot the app based on settings found in the database. Here is my code public void ConfigureServices(IServiceCollection services) { // Register context services.AddDbContext<AppDbContext>(options => { options.UseMySql(Configuration.GetConnectionString("MySqlServerConnection")); }); // Reister the setting

Troubleshooting 500.31 ANCM on Azure App Service

这一生的挚爱 提交于 2020-04-07 07:09:23
问题 After upgrading a project from ASP.NET Core 3.0 to ASP.NET Core 3.1 , my application stopped working on Azure App Services —but only when published using continuous deployment from Azure DevOps Pipelines . (Similar to another question, it continues to work if I publish directly from Visual Studio.) Specifically, the pipeline is still able to publish using the Azure App Service Deploy ( AzureRmWebAppDeployment ) task, but it fails to load in the Azure App Service environment with a 500.32

Troubleshooting 500.31 ANCM on Azure App Service

╄→尐↘猪︶ㄣ 提交于 2020-04-07 07:05:52
问题 After upgrading a project from ASP.NET Core 3.0 to ASP.NET Core 3.1 , my application stopped working on Azure App Services —but only when published using continuous deployment from Azure DevOps Pipelines . (Similar to another question, it continues to work if I publish directly from Visual Studio.) Specifically, the pipeline is still able to publish using the Azure App Service Deploy ( AzureRmWebAppDeployment ) task, but it fails to load in the Azure App Service environment with a 500.32

Asp Net Core 3.1 Authorization by Custom Roles

狂风中的少年 提交于 2020-03-26 03:30:33
问题 I've seen basically the same question answered for net core 2.2 on ASP Net Forum. When I tried to implement for my net core 3.1 application, I'm getting an error System.InvalidCastException: Unable to cast object of type 'System.Security.Claims.ClaimsIdentity' to type 'System.Security.Principal.WindowsIdentity' The error happens on the RoleAuthHandler.cs trying to cast Identity to WindowsIdentity. I'm wondering if there has been change between core 2.2 and 3.1 that explains this or I'm doing