asp.net-core-2.2

How to overload controller methods with same number of arguments in ASP.NET Core Web API?

断了今生、忘了曾经 提交于 2020-04-13 17:42:23
问题 I'm migrating a full .NET Framework Web API 2 REST project over to ASP.NET Core 2.2 and getting a bit lost in the routing. In Web API 2 I was able to overload routes with the same number of parameters based on the parameter type, e.g. I could have Customer.Get(int ContactId) and Customer.Get(DateTime includeCustomersCreatedSince) and incoming requests would be routed accordingly. I haven't been able to achieve the same thing in .NET Core, I either get a 405 error or a 404 and this error

How to keep the session alive after the browser is closed for 15 minutes using Identity in Core 2.2?

允我心安 提交于 2020-04-10 16:48:02
问题 I have an application written using C# on the top of ASP.NET Core 2.2 framework. I am using Identity to user management and user control. Currently, everytime a user closed his/her browser and open the app again, they are required to log in again. I want to change the login from a session into a cookie that expired after 15 minutes of being inactive. Here is what I have added to the Startup class public void ConfigureServices(IServiceCollection services) { services.AddDbContext

How to keep the session alive after the browser is closed for 15 minutes using Identity in Core 2.2?

被刻印的时光 ゝ 提交于 2020-04-10 16:45:13
问题 I have an application written using C# on the top of ASP.NET Core 2.2 framework. I am using Identity to user management and user control. Currently, everytime a user closed his/her browser and open the app again, they are required to log in again. I want to change the login from a session into a cookie that expired after 15 minutes of being inactive. Here is what I have added to the Startup class public void ConfigureServices(IServiceCollection services) { services.AddDbContext

How do I set “Parameter content type” using Swashbuckle?

最后都变了- 提交于 2020-03-01 01:37:12
问题 My swagger ui shows "Parameter content type" with various entries: "application/json-patch+json" , "text/json" , "application/json" , and "application/*+json" . I only want "application/json" . There's a similar unsolved issue on the repo, which uses this visual (older ui, but same idea): Is there some way to set this? Swashbuckle.AspNetCore version 4.0.1 Swashbuckle.AspNetCore.Filters version 4.5.5 回答1: Use the [Produces] and [Consumes] attributes. Swashbuckle (and others, like NSwag) will

Filling User Id Field in Application Insights from ASP.NET Core

≯℡__Kan透↙ 提交于 2020-02-23 05:13:58
问题 I would like to be able to populate the User Id field in Application Insights with my real username data. This is an internal application, so privacy concerns with a simple username field are moot. As far as I can tell, all solutions available online for this strictly work in .NET Framework, not .NET Core. You can find this solution in a few places, including some old AI documentation on GitHub. However, when I run it, I get an error on startup indicating that dependency on the scoped object

Select correct Angular Environment based on .Net Core build

丶灬走出姿态 提交于 2020-02-02 02:14:05
问题 I created an .Net Core Web Api with an Angular ClientApp with the templates from Visual Studio. When building the project also builds the contained Angular App with the params set in the .csproj <Target> section e.g. <Target Name="PublishRunWebpack" AfterTargets="ComputeFilesToPublish"> <!-- As part of publishing, ensure the JS resources are freshly built in production mode --> <Exec WorkingDirectory="$(SpaRoot)" Command="npm install" /> <Exec WorkingDirectory="$(SpaRoot)" Command="npm run

How to use shared SignalR Hub from different hosted project in ASP.NET Core 2.2

末鹿安然 提交于 2020-01-30 07:54:08
问题 The bounty expires in 4 days . Answers to this question are eligible for a +50 reputation bounty. Div wants to draw more attention to this question. I'm working with a project built with ASP.NET Core 2.2. The main solution contains multiple projects, which includes API, web and other class libraries. We've used SignalR to displaying shared messages/notifications between the API project and the web project. For example, adding a new employee record from an API should call SignalR Hub and all

Unable to update a record in asp.net-core 2.2 c#

我的未来我决定 提交于 2020-01-24 12:42:33
问题 I am trying to update the record of an item as follows [HttpPost] [ValidateAntiForgeryToken] public async Task<IActionResult> Edit(int id, [Bind("Id,Label,Description,LessonId,Position,FileName,Format,Status")] Content content) { if (id != content.Id) { return NotFound(); } var existingContent = await _context.Contents.FindAsync(id).ConfigureAwait(false); if (existingContent == null) { return NotFound(); } string fileToDelete = null; if (ModelState.IsValid) { try { if (Request.Form.Files[

Unable to update a record in asp.net-core 2.2 c#

*爱你&永不变心* 提交于 2020-01-24 12:41:48
问题 I am trying to update the record of an item as follows [HttpPost] [ValidateAntiForgeryToken] public async Task<IActionResult> Edit(int id, [Bind("Id,Label,Description,LessonId,Position,FileName,Format,Status")] Content content) { if (id != content.Id) { return NotFound(); } var existingContent = await _context.Contents.FindAsync(id).ConfigureAwait(false); if (existingContent == null) { return NotFound(); } string fileToDelete = null; if (ModelState.IsValid) { try { if (Request.Form.Files[

How to create database in Microsoft SQL Server using linq2db by code first approach in .NET CORE 2.2

安稳与你 提交于 2020-01-22 02:31:13
问题 Created new project in .net core 2.2 and installed nuget package linq2db.sqlserver using this package i am able to do CRUD with database first approach but i need to know how to do CRUD using code first approach. 回答1: Linq2Db has a link https://linq2db.github.io/index.html which provides more information about how to create a POCO and create a table based on it. As per the page, a simple POCO can go like this: using System; using LinqToDB.Mapping; [Table(Name = "Products")] public class