![](/img/trans.png)
[英]ASP.NET Core 7 valditate IAsyncEnumerable against data annotation
如何在 ASP.NET Core 7 API controller POST 操作中對作為 IAsyncEnumerable 的輸入執行數據注釋驗證。 我嘗試使用以下代碼,但未進行驗證。public record struct Car([Required][RegularExpression(@" ...
[英]ASP.NET Core 7 valditate IAsyncEnumerable against data annotation
如何在 ASP.NET Core 7 API controller POST 操作中對作為 IAsyncEnumerable 的輸入執行數據注釋驗證。 我嘗試使用以下代碼,但未進行驗證。public record struct Car([Required][RegularExpression(@" ...
[英]Core 7 - Api error handling, model state validation + UseExceptionhandler
我目前正在使用 swagger/swashbuckle in.net core 7 實現一些 Apis 並實現一些錯誤處理,我已經走上了使用異常處理程序的路線。 具有來自開發/生產的單獨端點。 例如 Startup.cs 錯誤控制器.cs 這個想法是所有響應都是 IAttempt 的,因此 FE ...
[英]Upgrade my Azure Function from .net Core 3.1 to .net Core 7.0. Error "'Could not load file or assembly 'Microsoft.Extensions.Configuration.Abstraction
我有一個運行在 .net 核心 3.1 上的 Azure Function,但是當我將 .net 版本從 3.1 更改為 7 時,我收到了這個錯誤:- 這是一個屏幕截圖:- 這是我的 csproj 文件:- 請問有什么建議嗎? 我已經安裝了Install-Package Microsoft.Ex ...
[英]How do you post back to the controller from an icons onclick event
項目類型:ASP.NET Core 7 MVC web 應用。 單擊檢查圓圈圖標時,我試圖發回 controller,但出現錯誤,因為該操作是用HttpPost裝飾的。 當我將其更改為HttpGet時,錯誤消失了。 我如何讓它回發? ...
[英]How to add controller endpoints to Razor Server in ASP.NET Core 7.0 / VS2022
我正在嘗試添加一個 controller 並路由到 Razor 服務器端應用程序。 我嘗試了幾件事,但我只看到 .NET 6 的解決方案,無法弄清楚。 我這樣創建了一個 controller: 然后在我的program.cs中添加: 和 AFAIK 這應該有效,端點http://localhost ...
[英]What is causing DbSet<T> does not contain a definition for GetAwaiter error message?
我正在關注 Contoso University 的 MVC 版本教程,網址為: https://learn.microsoft.com/en-us/as.net/core/data/ef-mvc/update-related-data?view=as。 netcore-7.0 本教程在 .Net ...
[英]How do you configure Brighter with ASP.NET Core 7?
如何使用 ASP.NET Core 7 配置 Brighter? Brighter 文檔在細節上相當稀疏,inte.net 上的示例似乎也已過時。 web 上是否有示例啟動代碼 (Program.cs) 和基本的 Controller? https://www.goparamore.io/ ...
[英]How do you access HttpContext from within _Layout.cshtml
項目:ASP.NET Core 7 MVC web 應用我已將 object 添加到 controller 中的HttpContext.Items集合中,我正在嘗試訪問 object 以隱藏_Layout.cshtml中的一些菜單選項,但出現錯誤 Object 需要參考如何設置參考? ...
[英]How does .NET Core C# Minimal API fill parameters?
使用簡約 API MapGet如何自動填充查詢字符串中的參數? 使用 minimalistic API,以下是可能的: 當您神奇地調用: /api/Students/Grades?studentId=5時,studentId 將傳遞給 GetGradesAsync、ClaimsPrinicipal ...
[英]How to create a Net Core Middleware to validate a route parameter
使用 Net Core 7 我有 Razor 個帶有culture路由參數的頁面: 我創建了一個自定義路由約束來檢查culture是否具有有效值。 當culture值無效時,我將被重定向到 404 錯誤頁面。 如果我對有效文化進行硬編碼,這會很好用,例如: 但是如果我注入RequestLocaliz ...
[英]How to handle NullProviderCultureResult? Isn't it strange to render the homepage without redirection?
在 Net 7 項目中,我在Program中設置本地化: 我有兩個 Razor 頁面(索引和關於): 我可以使用以下方式訪問主頁(索引): 但我只能使用以下方法訪問“關於”頁面: 當我嘗試訪問“/about”時,url 沒有更改,但呈現主頁。 這不奇怪嗎? 不應該重定向到索引並更改索引 Url 嗎 ...
[英]Create Report in ASP.NET Core 7 MVC using C# in Visual Studio Community 2022
過去(很久以前)我使用 Crystal Report 來制作報告,現在我正在使用 Visual Studio 2022。我正在嘗試為 ASP.NET Core 7 MVC 制作報告,我從 Marketplace 找到並安裝了 Microsoft RDLC Report Designer 並提供我有機 ...
[英]How can I change this problem for ASP.NET Core 7.0?
這個項目是在.NET 4.6上為ASP.NET創建的,但現在我會嘗試將它移動到ASP.NET Core 7.0。 在 ASP.NET Core 7 中,我可以寫什么來代替這段代碼? 舊的LoginController : 它創建了一個新的 cookie,所以對我沒有幫助 ...
[英]How to get foreign key linked values while using generic repository and unit of work patterns with Entity Framework Core
我是 Entity Framework Core 7 和 ASP.NET Core 7 MVC 的新手。 我正在使用 Northwind 數據庫學習這些概念。 我在 EF Core 之上使用通用存儲庫和 UnitOfWork 模式進行數據訪問。 我創建了一個ProductsController並在視 ...
[英]ASP.NET Core 7 Integration Test with CustomWebApplicationFactory<TProgram> Client always returns 404 not found
我的asp.net core 7 web api應用程序正在使用Program.cs和Startup.cs運行。 我已經使用CustomWebApplicationFactory<TStartup>編寫了我的Integration Tests 。 一切都按預期工作。 現在我決定離開St ...
[英]Connect Appwrite auth with ASP.NET Core 7
我正在嘗試使用我的 ASP.NET Core 7 Web API 對 Appwrite 用戶進行身份驗證。過去,我使用 Firebase 來實現 function,如下所示:private static void ConfigureFirebaseAuthentication(IServiceCo ...
[英]I'm getting a transient failure with MySQL and MariaDB
我正在研究一個簡單的 Web API,它使用 MySQL 作為數據庫。 這是非常基本的: 這個想法很簡單。 這是一個中間件方法,它根據響應中的狀態代碼將所有請求寫入數據庫,無論是“有效”還是“無效”。 這個 API 可能每小時收到大約 10 個請求,所以它應該可以工作。 除了它不... 如果有的話, ...
[英]NU1107: Version conflict detected for Microsoft.CodeAnalysis.Common
我在嘗試構建導致我運行 package 恢復的應用程序時遇到問題,但失敗了,我也無法更新包。 我安裝了最新的 SDK: 整個解決方案(每個項目)設置為 .net 7.0:<TargetFramework>net7.0</TargetFramework> global.j ...
[英]How to apply at once StringLength attribute to all properties within the class?
我有一個 class 和 ~400 個字符串屬性(它是自動生成的)我想將[StringLength(50)]應用於 class 中的所有屬性。如果不將屬性復制粘貼 400 次,這是否可能? ...
[英]Setting a form's action manually, no Antiforgery is auto-injected
當我手動設置action屬性時,“Antiforgery”元素/令牌丟失(不是自動生成/注入的) 部分視圖中的代碼(部分) 渲染代碼(客戶端) 但是當我省略action時,它會被創建(在客戶端中呈現代碼)。 這是默認行為嗎,如果想手動設置action ,還需要手動添加“防偽”元素嗎? 一張紙條如果使 ...