.net-core-3.0

MissingFieldException: Field not found: 'Microsoft.Net.Http.Headers.HeaderNames.Authorization'

China☆狼群 提交于 2019-12-10 22:49:51
问题 I making an API with .NET Core 3.0 Preview 4 CLI . I've came up to the point where you can send username and password and get the token (JWT). This is my login method. [HttpPost("login")] public async Task<IActionResult> Login([FromBody] UserForLoginDto userForRegisterDto) { var userFromRepo = await _repo.Login(userForRegisterDto.Username.ToLower(), userForRegisterDto.Password); if (userFromRepo == null) //User login failed return Unauthorized(); //generate token var tokenHandler = new

How to Separate Code From UI In Blazor.Net

心已入冬 提交于 2019-12-07 23:08:51
问题 Reference to this VisualStudioMagazine article, I am trying to have code in a separate file instead of razor view. I tried: @page "/Item" @using WebApplication1.Shared @using WebApplication1.Client.Services; @inject HttpClient Http @inherits ItemComponent @if (ItemList != null) { <table class="table"> <thead> <tr> <th>ID</th> <th>Name</th> <th>Category</th> <th>Metal</th> <th>Price</th> <th>Quantity</th> </tr> </thead> <tbody> @foreach (var item in ItemList) { <tr> <td>@item.ID</td> <td>@item

Exception parsing json with System.Text.Json.Serialization

瘦欲@ 提交于 2019-12-07 22:58:24
问题 My sample code is very simple: using System.Text.Json.Serialization; using Newtonsoft.Json; public class C { public C(string PracticeName) { this.PracticeName = PracticeName; } public string PracticeName; } var x = new C("1"); var json = JsonConvert.SerializeObject(x); // returns "{\"PracticeName\":\"1\"}" var x1 = JsonConvert.DeserializeObject<C>(json); // correctly builds a C var x2 = System.Text.Json.Serialization.JsonSerializer.Parse<C>(json); the last line raises: Exception thrown:

Converting newtonsoft code to System.Text.Json in .net core 3. what's equivalent of JObject.Parse and JsonProperty

断了今生、忘了曾经 提交于 2019-12-07 15:06:37
问题 I am converting my newtonsoft implementation to new JSON library in .net core 3.0. I have the following code public static bool IsValidJson(string json) { try { JObject.Parse(json); return true; } catch (Exception ex) { Logger.ErrorFormat("Invalid Json Received {0}", json); Logger.Fatal(ex.Message); return false; } } I am not able to find any equivalent for JObject.Parse(json); Also what will be the attribute JsonProperty equivalent public class ResponseJson { [JsonProperty(PropertyName =

Exception parsing json with System.Text.Json.Serialization

笑着哭i 提交于 2019-12-06 13:23:56
My sample code is very simple: using System.Text.Json.Serialization; using Newtonsoft.Json; public class C { public C(string PracticeName) { this.PracticeName = PracticeName; } public string PracticeName; } var x = new C("1"); var json = JsonConvert.SerializeObject(x); // returns "{\"PracticeName\":\"1\"}" var x1 = JsonConvert.DeserializeObject<C>(json); // correctly builds a C var x2 = System.Text.Json.Serialization.JsonSerializer.Parse<C>(json); the last line raises: Exception thrown: 'System.NullReferenceException' in System.Text.Json.dll Object reference not set to an instance of an object

How to Separate Code From UI In Blazor.Net

我怕爱的太早我们不能终老 提交于 2019-12-06 05:48:37
Reference to this VisualStudioMagazine article, I am trying to have code in a separate file instead of razor view. I tried: @page "/Item" @using WebApplication1.Shared @using WebApplication1.Client.Services; @inject HttpClient Http @inherits ItemComponent @if (ItemList != null) { <table class="table"> <thead> <tr> <th>ID</th> <th>Name</th> <th>Category</th> <th>Metal</th> <th>Price</th> <th>Quantity</th> </tr> </thead> <tbody> @foreach (var item in ItemList) { <tr> <td>@item.ID</td> <td>@item.Name</td> <td>@item.Category</td> <td>@item.Metal</td> <td>@item.Price</td> <td>@item.Quantity</td> <

The “TransformAppSettings” task failed unexpectedly

陌路散爱 提交于 2019-12-06 05:13:40
问题 I have a .NET Core 3 Blazor (server side) application which I recently upgraded to .NET Core 3.0.1 preview 6 version from the preview 5 version. When I build and run it locally, it works fine; but when trying to publish it to a file system folder (in Framework-Dependent mode), it throws this error: C:\Program Files\dotnet\sdk\3.0.100-preview6-012264\Sdks\Microsoft.NET.Sdk.Publish\targets\TransformTargets\Microsoft.NET.Sdk.Publish.TransformFiles.targets(192,5): Error MSB4018: The

Converting newtonsoft code to System.Text.Json in .net core 3. what's equivalent of JObject.Parse and JsonProperty

点点圈 提交于 2019-12-06 02:58:54
I am converting my newtonsoft implementation to new JSON library in .net core 3.0. I have the following code public static bool IsValidJson(string json) { try { JObject.Parse(json); return true; } catch (Exception ex) { Logger.ErrorFormat("Invalid Json Received {0}", json); Logger.Fatal(ex.Message); return false; } } I am not able to find any equivalent for JObject.Parse(json); Also what will be the attribute JsonProperty equivalent public class ResponseJson { [JsonProperty(PropertyName = "status")] public bool Status { get; set; } [JsonProperty(PropertyName = "message")] public string Message

Enum type no longer working in .Net core 3.0 FromBody request object

旧街凉风 提交于 2019-12-05 21:21:32
I have recently upgraded my web api from .Net core 2.2 to .Net core 3.0 and noticed that my requests are getting an error now when I pass an enum in a post to my endpoint. For example: I have the following model for my api endpoint: public class SendFeedbackRequest { public FeedbackType Type { get; set; } public string Message { get; set; } } Where the FeedbackType looks like so: public enum FeedbackType { Comment, Question } And this is the controller method: [HttpPost] public async Task<IActionResult> SendFeedbackAsync([FromBody]SendFeedbackRequest request) { var response = await

The “TransformAppSettings” task failed unexpectedly

被刻印的时光 ゝ 提交于 2019-12-04 12:31:18
I have a .NET Core 3 Blazor (server side) application which I recently upgraded to .NET Core 3.0.1 preview 6 version from the preview 5 version. When I build and run it locally, it works fine; but when trying to publish it to a file system folder (in Framework-Dependent mode), it throws this error: C:\Program Files\dotnet\sdk\3.0.100-preview6-012264\Sdks\Microsoft.NET.Sdk.Publish\targets\TransformTargets\Microsoft.NET.Sdk.Publish.TransformFiles.targets(192,5): Error MSB4018: The "TransformAppSettings" task failed unexpectedly. System.IO.FileNotFoundException: Could not load file or assembly