Use this tag for questions specifically related to version 7.0 of the .NET platform. For questions on .NET Framework generally, use the .net tag.
Questions tagged [.net-7.0]
1169 questions
3
votes
1 answer
Foreign key issue: EF Core 7 code-first: "Cannot insert explicit value for identity column in table '' when IDENTITY_INSERT is set to OFF."
I'm sure the issue is in OnModelCreating but I'm not sure what's missing. I'm trying to create two DbSets, one for SocialMediaUrls with a foreign key to SocialMediaTypes. When I'm trying to insert a row into SocialMediaUrls, the code is also trying…

Dave Koppe
- 31
- 2
3
votes
0 answers
TLS1.0 no longer working after upgrade of service from .Net Core 3.1 to .Net 7.0
(Edited: have now confirmed that the thing that stopped this working was NOT a windows update, but an update to our service app)
We have a .Net 7 Web API service, running using Kestrel.
This service used to work, but it seems that upgrading it from…

GPW
- 2,528
- 1
- 10
- 22
3
votes
2 answers
'WorkerOptions' does not contain a definition for 'AddApplicationInsights' in isolated Azure function program.cs file
I'm getting this dependency error below and I'm not sure why? I manually added "Microsoft.Extensions.DependencyInjection" package to try and fix the dependency error and have it referenced in my .csproj file. and I have the using statement at the…

chuckd
- 13,460
- 29
- 152
- 331
3
votes
1 answer
.Net 7 slow response times from HTTPClient request every 6 minutes
We are experiencing an issue with HTTP requests where we are seeing that every 6 minutes a HTTP request is taking up to 162ms, on average these requests are taking 7ms. The metrics graph below shows a brief run of a K6 script calling our controller…

Alan Mulligan
- 1,107
- 2
- 16
- 35
3
votes
0 answers
Navigation does not work in WinForms BlazorWebView
The Blazor sample app is correctly rendered in the WinForms BlazorWebView but navigation does not work.
I've followed this tuto : https://learn.microsoft.com/en-us/aspnet/core/blazor/hybrid/tutorials/windows-forms?view=aspnetcore-7.0
Visual Studio…

PaulDurant
- 51
- 1
- 4
3
votes
1 answer
ActionFilterAttribute: HttpContext.Request.Body always empty
I am trying to get the request body in an ActionFilterAttribute.
The JSON value is always "". I am using .NET7.0 and I also added below code to Program.cs
.Use(async (context, next) =>
{
try
{
…

MRSeen
- 31
- 3
3
votes
2 answers
EF Core, efficient way of adding a multitude of large entities to the many-to-many relationship of another entity?
lets say I have two Models, Tags and Posts, and the Tag Model is very large (lots of columns). A Tag can have Multiple posts, and a Post can have multiple Tags.
The only way I know how to set relationships between Tags and Posts is by doing
var…

Daniel Goldberg
- 101
- 6
3
votes
0 answers
Transferring a file over a serial port in .NET 7.0 (C#)
I am currently using the .NET 7.0 framework in Visual Studio. I am trying to transfer a file over a serial port however I am having some trouble. I am just wondering if there is a NuGet package or something I must do in order to enable me to…

Jack
- 41
- 4
3
votes
2 answers
Purpose of `AsMemory()` applied to `byte[]` in `FileStream`
I'm revising the code and notice that I get a suggestion to use the extension method AsMemory(...). I've never seen it before nor ha a reason to consider it. Never the less, one's either learn och obsoletes, so I got intrigued.
After reading the…

Konrad Viltersten
- 36,151
- 76
- 250
- 438
3
votes
1 answer
Setting all reference to an object to null
I have this example code which is incomplete because I don't know how to do what I'm trying to do.
// This class will never be garbage collected
// It is the core to my Game Engine Loop.
public class Application
{
…

LJH
- 82
- 6
3
votes
1 answer
Error NETSDK1152 on WinUI3 App: Found multiple publish output files with the same relative path: Microsoft.Web.WebView2.Core.dll
Installed Visual Studio 2022 (on a clean/fresh Windows 11 installation), installed Template Studio for WinUI (v5.3).
Created a Project using Template Studio with these Settings:
- Project type: Navigation pane
- Design pattern: MVVM…

Mladen Gavrić
- 75
- 7
3
votes
1 answer
ASP.NET Core MVC URL : magic that makes HomeController become /Home in .NET 7
I'm trying to understand the under the hood magic that seems to be happening with ASP.NET Core MVC.
I create a new controller DefaultTomatoController, using "New Scaffold Item: MVC Controller - Empty"
Code is simply:
using…

Rob K.
- 519
- 6
- 16
3
votes
0 answers
ASP.NET 7 - Routing to SPA vs. Controller
Im trying to setup a new ASP.NET 7 WebApplication with a React-SPA and Api-Controllers.
The problem Im facing is, that every request just hits the SPA, even if a controller should handle the request.
I use the following code to setup my…

user1704029
- 265
- 2
- 9
3
votes
1 answer
Using Numeric literals/constants in Generic Math C# 11
I am working with the new Generic Math System in C# 11, which is cool, but I haven't found a way to use numeric literals or mathematical constants with them.
The following example which calculates the circumference of a circle does not work.
public…

paulmattern
- 33
- 3
3
votes
1 answer
How to setup dotnet Testcontainers with a SQL Server database for Integration Tests?
I have an API REST .NET 7 and I want to build integrations tests using a sql server container database.
I've tried to follow the example in the documentation (https://dotnet.testcontainers.org/examples/aspnet/):
const string weatherForecastStorage =…

Ezequiel Irigoyen
- 105
- 2
- 6