asp.net-core-3.0

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> <

JsonResult(object) causes “The collection type 'Newtonsoft.Json.Linq.JToken' is not supported.”

那年仲夏 提交于 2019-12-06 01:39:28
I upgraded an existing ASP.NET Core 2.2 project to 3.0. I have a method that returns JSON which worked in 2.2, but in 3.0, it causes "The collection type 'Newtonsoft.Json.Linq.JToken' is not supported." at the return. [HttpGet()] public async Task<JsonResult> Get() { var res = some class object in a third-party library; return new JsonResult(res); } I have searched Google and found that Microsoft has replaced Newtonsoft Json to System.Text.Json , but I have not explicitly used Newtonsoft Json. In the project's "Frameworks", I could see the Newtonsoft Json, and I removed it and the using

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

What is equivalent to `MapSpaFallbackRoute` for ASP.NET Core 3.0 endpoints?

£可爱£侵袭症+ 提交于 2019-12-05 00:53:44
In ASP.NET Core 2.x I used standard routes registation Configure method of Startup class to register fallback route for SPA application using MapSpaFallbackRoute extension method from Microsoft.AspNetCore.SpaServices.Extensions Nuget package: public void Configure(IApplicationBuilder app) { // ... app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); routes.MapSpaFallbackRoute( name: "spa-fallback", defaults: new { controller = "Home", action = "Index" }); }); } I cannot find similar extension method when using ASP.NET Core 3.0

'IHostingEnvironment' is obsolete

给你一囗甜甜゛ 提交于 2019-12-03 22:54:18
I updated my project to .NETCORE v3.0.0-preview3 and I now get: Startup.cs(75,50,75,69): warning CS0618: 'IHostingEnvironment' is obsolete: 'This type is obsolete and will be removed in a future version. The recommended alternative is Microsoft.AspNetCore.Hosting.IWebHostEnvironment.' The code is: public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { ... What is the correct way to do this now ? is there any documentation/example to show that ? It seems IHostingEnvironment has been replaced by IHostEnvironment (and a few others). You should be able

Is it possible to get a list of RenderFragments when overriding BuildRenderTree?

 ̄綄美尐妖づ 提交于 2019-12-02 08:33:38
I'm wondering if it's possible to reference child elements in the ChildContent parameter of a component. I can pass values from parent components to children explicitly or by using a cascading parameter, but there is no great way for a parent component to "know" about elements inside the ChildContent RenderFragment . A possible use-case for this would be a UIList component that gets the number of UIListItems that have been added to the UIList component during the render process. I've attempted to override the BuildRenderTree method on my component to manually manipulate ChildContent

Migrate from ASP.NET Core 2.0 to 3.0

馋奶兔 提交于 2019-12-01 14:57:18
问题 I have an application in ASP.NET Core 2.0. I want to upgrade it to ASP.NET Core 3.0. How can I do that? 回答1: Follow this link. This will give some guidance for your migration. https://docs.microsoft.com/en-us/aspnet/core/migration/22-to-30?view=aspnetcore-2.2&tabs=visual-studio As stated in the comments, the complete path of migration from 2.0 to 3.0 would be: Migrate from ASP.NET Core 2.0 to 2.1 Migrate from ASP.NET Core 2.1 to 2.2 Migrate from ASP.NET Core 2.2 to 3.0... You will have to go

Azure functions stopped working after Core 3.0 update

六眼飞鱼酱① 提交于 2019-12-01 13:38:39
The code is working in Core 3.0 preview7 version, but after updating to 3.0 Azure functions started giving an error. The error comes if I try to access builder service object. Also not able to debug the issue. Also tried updating Microsoft.Extensions.DependencyInjection 3.0 but still the same error. public class Startup : FunctionsStartup { public override void Configure(IFunctionsHostBuilder builder) { var descriptor = builder.Services.FirstOrDefault(d => d.ServiceType == typeof(IConfiguration)); // error after adding this var currentDirectory = $"{Environment.GetEnvironmentVariable("HOME")}\

Is it possible to change .cshtml View and see the changes instantly using .NET Core?

本秂侑毒 提交于 2019-12-01 08:01:23
Context In my NET Framework 4.x ASP MVC projects, when using the IDE, it was possible to edit a .cshtml View, then save, then press ctrl+F5 in the browser and see the actual change. It seems to be not working in .NET Core (using VS 2019 and .NET Core 3 Preview 5) Question Is this feature missing in .NET Core or is this a preview issue, or am I missing something? This is something that is no longer enabled by default as of ASP.NET Core 3, but it can be re-enabled as documented here : Runtime compilation is enabled using the Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation package. To enable

'IHostingEnvironment' is obsolete

十年热恋 提交于 2019-11-30 00:27:40
问题 I updated my project to .NETCORE v3.0.0-preview3 and I now get: Startup.cs(75,50,75,69): warning CS0618: 'IHostingEnvironment' is obsolete: 'This type is obsolete and will be removed in a future version. The recommended alternative is Microsoft.AspNetCore.Hosting.IWebHostEnvironment.' The code is: public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { ... What is the correct way to do this now ? is there any documentation/example to show that ?