.net-core

How to bind a multipart/form-data file without filename to IFormFile in ASP.NET Core

断了今生、忘了曾经 提交于 2021-02-07 10:10:25
问题 In a simple controller action in ASP.NET Core 3.1 that accepts multipart/form-data parameters: using System.ComponentModel.DataAnnotations; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; namespace WebApplication { public class Controller : ControllerBase { [HttpPost("length")] public IActionResult Post([FromForm] Input input) { if (!ModelState.IsValid) return new BadRequestObjectResult(ModelState); return Ok(input.File.Length); } public class Input { [Required] public

WCF Change message encoding from Utf-16 to Utf-8

怎甘沉沦 提交于 2021-02-07 10:09:46
问题 I have a WCF connected service in a .net core application. I'm using the code that is autogenerated taken the wsdl definition. Currently at the top of the request xml is including this line: <?xml version="1.0" encoding="utf-16"?> I can't find a simple way to change this encoding to UTF-8 when sending the request. Since I could find a configuration option a the request/client objects, I've tried to change the message with following code at IClientMessageInspector.BeforeSendRequest public

WCF Change message encoding from Utf-16 to Utf-8

故事扮演 提交于 2021-02-07 10:09:00
问题 I have a WCF connected service in a .net core application. I'm using the code that is autogenerated taken the wsdl definition. Currently at the top of the request xml is including this line: <?xml version="1.0" encoding="utf-16"?> I can't find a simple way to change this encoding to UTF-8 when sending the request. Since I could find a configuration option a the request/client objects, I've tried to change the message with following code at IClientMessageInspector.BeforeSendRequest public

Is there a way to have .NET Framework code in a .NET Core library?

我只是一个虾纸丫 提交于 2021-02-07 10:01:56
问题 We have a commercial library that I am working to port to .NET Core. There are a couple of calls in it I want to retain to use only if running in .NET standard. (For the curious, one set is to read a file on a Windows server that requires credentials to access.) Is there: A call that will tell me if I am running under .NET Standard vs. .NET Core. Is there a way to have a class that is only going to be instantiated/called if running under standard, but the DLL will still load fine under Core?

Dotnet core with SOAP service

↘锁芯ラ 提交于 2021-02-07 09:34:51
问题 We have a ASP.NET Core system and we need to connect to another webservice using SOAP (we received the WSDL from the customer). In the past, we should have use the "add service reference" using WCF options in Visual Studio. For dotnet core projects, the options is no more available but there are several options to get the same solutions: Use SvcUtil in the command line or install the plugin here https://blogs.msdn.microsoft.com/webdev/2016/06/26/wcf-connected-service-for-net-core-1-0-0-and

Localizing Enum entry on asp.net core

半世苍凉 提交于 2021-02-07 08:18:27
问题 How can I localize the following enum entries on asp.net core? I found few issues on asp.net-core github repository ( https://github.com/aspnet/Mvc/pull/5185 ), but I can't find a proper way to do it. Target enum: public enum TestEnum { [Display(Name = "VALUE1_RESX_ENTRY_KEY")] Value1, [Display(Name = "VALUE3_RESX_ENTRY_KEY")] Value2 } CSHTML code block: <select id="test" asp-items="Html.GetEnumSelectList<TestEnum>()"> </select> Resource files: 回答1: It seems to be a bug which will be fixed in

Localizing Enum entry on asp.net core

允我心安 提交于 2021-02-07 08:17:53
问题 How can I localize the following enum entries on asp.net core? I found few issues on asp.net-core github repository ( https://github.com/aspnet/Mvc/pull/5185 ), but I can't find a proper way to do it. Target enum: public enum TestEnum { [Display(Name = "VALUE1_RESX_ENTRY_KEY")] Value1, [Display(Name = "VALUE3_RESX_ENTRY_KEY")] Value2 } CSHTML code block: <select id="test" asp-items="Html.GetEnumSelectList<TestEnum>()"> </select> Resource files: 回答1: It seems to be a bug which will be fixed in

Localizing Enum entry on asp.net core

自闭症网瘾萝莉.ら 提交于 2021-02-07 08:17:47
问题 How can I localize the following enum entries on asp.net core? I found few issues on asp.net-core github repository ( https://github.com/aspnet/Mvc/pull/5185 ), but I can't find a proper way to do it. Target enum: public enum TestEnum { [Display(Name = "VALUE1_RESX_ENTRY_KEY")] Value1, [Display(Name = "VALUE3_RESX_ENTRY_KEY")] Value2 } CSHTML code block: <select id="test" asp-items="Html.GetEnumSelectList<TestEnum>()"> </select> Resource files: 回答1: It seems to be a bug which will be fixed in

Select only specific fields with Linq (EF core)

霸气de小男生 提交于 2021-02-07 07:21:31
问题 I have a DbContext where I would like to run a query to return only specific columns, to avoid fetching all the data. The problem is that I would like to specify the column names with a set of strings, and I would like to obtain an IQueryable of the original type, i.e. without constructing an anonymous type. Here is an example: // Install-Package Microsoft.AspNetCore.All // Install-Package Microsoft.EntityFrameworkCore using Microsoft.EntityFrameworkCore; using System; using System.Linq;

dotnet publish include extra files

白昼怎懂夜的黑 提交于 2021-02-07 06:17:05
问题 I have a netcore application depends on my custom project. Because I cannot reference it directly, I have written postbuildevents that are copying my files to output: xcopy "$(SolutionDir)Ethereum.Contracts\bin\$(ConfigurationName)\*.abi" "$(TargetDir)" /Y /I xcopy "$(SolutionDir)Ethereum.Contracts\bin\$(ConfigurationName)\*.bin" "$(TargetDir)" /Y /I It works fine when I build and run project, but when run publish command it doesn't include these files. How can it be done? I tried this