asp.net-core

RequestSizeLimitAttribute: HTTP 500 instead of 413 in ASP.NET Core 2.1.401

断了今生、忘了曾经 提交于 2021-02-18 12:10:30
问题 I have [RequestSizeLimit] on my API controller, and it kinda works as expected: requests bigger than specified limit are rejected. [HttpPut] [RequestSizeLimit(120_000_000)] public async Task<IActionResult> Put(IFormCollection form) { ... } The problem is, an exception is thrown: Microsoft.AspNetCore.Server.Kestrel.Core.BadHttpRequestException: Request body too large. at Microsoft.AspNetCore.Server.Kestrel.Core.BadHttpRequestException.Throw(RequestRejectionReason reason) at Microsoft

RequestSizeLimitAttribute: HTTP 500 instead of 413 in ASP.NET Core 2.1.401

喜欢而已 提交于 2021-02-18 12:09:23
问题 I have [RequestSizeLimit] on my API controller, and it kinda works as expected: requests bigger than specified limit are rejected. [HttpPut] [RequestSizeLimit(120_000_000)] public async Task<IActionResult> Put(IFormCollection form) { ... } The problem is, an exception is thrown: Microsoft.AspNetCore.Server.Kestrel.Core.BadHttpRequestException: Request body too large. at Microsoft.AspNetCore.Server.Kestrel.Core.BadHttpRequestException.Throw(RequestRejectionReason reason) at Microsoft

“Did you mean to run dotnet SDK commands? Please install dotnetsdk” in windows command prompt

笑着哭i 提交于 2021-02-18 11:59:23
问题 I have just installed dot net core sdk and runtime (2.2.1) on my system viz. a Windows Server 2012R2. I am trying to create a console app using the command prompt using dotnet new console but it says Did you mean to run dotnet SDK commands? Please install dotnetsdk Is there any other configurations needed. The Environment path variable also contains the following folder C:\Program Files\dotnet. I have not installed VS2017. Was trying to use VS Code 回答1: Please, make sure you've installed SDK

Create a custom Model Binder for a custom type

≡放荡痞女 提交于 2021-02-18 10:10:48
问题 In an ASP.NET CORE 1.1 project I have the following model: public class GetProductsModel { public OrderExpression OrderBy { get; set; } } OrderExpression is a class which has the following method: Boolean TryParse(String value, out OrderExpression expression) The method creates a OrderExpression instance from a String and can be used: OrderExpression expression; Boolean parsed = OrderExpression.TryParse(value, out expression); How can I create a custom Model Binder to properties of type

Optional Model Properties Binding in .NET Core MVC

六眼飞鱼酱① 提交于 2021-02-18 08:42:31
问题 I have created one AccountModel which has following properties public class AccountModel { [Required] [EmailAddress] public string Email { get; set; } [Required] [StringLength(10, MinimumLength = 6)] public string Password { get; set; } [NotMapped] // Does not effect with your database [Compare("Password")] [BindRequired] public string ConfirmPassword { get; set; } } I am trying to use same model for SignUp and SignIn . This model is perfectly working for signup but when I am using same model

Asp Core: Azure Ad Auth + custom JWT + custom Identity store

江枫思渺然 提交于 2021-02-18 08:41:21
问题 With ASP.NET Core 2.0 I try to achieve the following: Authentication via Azure AD (registered App) Custom JWT as the authentication scheme to make the the web app auth work across servers/instances be able to save the bearer to login with desktop clients Have a custom identity store to introduce custom roles, policies, and other. All these parts have working examples, but while trying to combine them I stumbled over some problems. The Web Api + Azure Ad Auth example uses JWT Tokens for

How can I keep my model in my View after OnPost?

孤者浪人 提交于 2021-02-18 07:44:16
问题 I'm on a project with .Net Core and I'm using ASP Razor Pages. In my model, I have an OnGet which load all the data I need in my view. public IList<Projet> Projets { get; set; } public ActionResult OnGet() { Projets = _serviceSelect.getProjets(); return Page(); } Then, in my OnPost which is activated when I submit my form. <form method="post"> <div asp-validation-summary="All" class="text-danger"></div> <input type="radio" value="1" asp-for="LoginData.TypeCompte" />choice<br /> Username:

passing docker environment variables to .net core

让人想犯罪 __ 提交于 2021-02-18 07:34:29
问题 I've followed this article and the code on the github doesn't compile, tutorial is outdated I think. ( Configuration = builder.Build(); ) throws error. So how can I access env passed from docker? docker-compose myproj: image: mcr.microsoft.com/dotnet/core/sdk:2.2 restart: on-failure working_dir: /MyProj command: bash -c "dotnet build MyProj.csproj && dotnet bin/Debug/netcoreapp2.2/MyProj.dll" ports: - 5001:5001 - 5000:5000 volumes: - "./MyProj:/MyProj" environment: DATABASE_HOST: database

Publishing a dotnet application that's already running

a 夏天 提交于 2021-02-18 06:26:42
问题 I'm attempting to create a script to simplify the process of publishing a .NET Core website. I'm running into an issue when I run dotnet publish against an already running server. The server is IIS with the dotnet bundle installed, so IIS uses its app pool to start dotnet. Here's my batch file. I'm happy to use another script type: cd src/app dotnet build --no-incremental dotnet publish --framework netcoreapp1.0 --configuration Release --output ../../dist When I run the script I get this

Publishing a dotnet application that's already running

扶醉桌前 提交于 2021-02-18 06:26:17
问题 I'm attempting to create a script to simplify the process of publishing a .NET Core website. I'm running into an issue when I run dotnet publish against an already running server. The server is IIS with the dotnet bundle installed, so IIS uses its app pool to start dotnet. Here's my batch file. I'm happy to use another script type: cd src/app dotnet build --no-incremental dotnet publish --framework netcoreapp1.0 --configuration Release --output ../../dist When I run the script I get this