小编MrJ*_*bin的帖子

刷新 Blazor 页面

使用 .NET 6 的 Blazer 服务器端项目中,我位于以下页面:

\n

https://localhost:7252/Product/a3620f82-7cba-473c-9273-1cf300a181eb

\n

我在此页面上有一个导航链接,它指向上面完全相同的 URL。但是当我点击该方法时,页面没有任何反应,也没有刷新或更新。我应该怎么办?

\n

我的代码示例:

\n
@page "/Product/{Id:guid}"\n@using Application.ProductGalleries.Queries\n@using Application.Products.Queries\n@using ViewModels.ProductVariants\n@using ViewModels.ProductVariantsDetails\n@using ViewModels.Products\n<div class="col-12 px-0">\n                        <h1>\n                            <NavLink href="@($"/Product/a3620f82-7cba-473c-9273-1cf300a181eb")">@Model.ProductName</NavLink>\n                            </h1>\n                        <p>\xd8\xaf\xd8\xb3\xd8\xaa\xd9\x87 \xd8\xa8\xd9\x86\xd8\xaf\xdb\x8c : @Model.CategoryName<span> \xd8\xa8\xd8\xb1\xd9\x86\xd8\xaf: @Model.BrandName</span></p>\n                        <nav aria-label="breadcrumb">\n                            <ol class="breadcrumb">\n                                <li class="breadcrumb-item"><NavLink href="/">\xd8\xb5\xd9\x81\xd8\xad\xd9\x87 \xd9\x86\xd8\xae\xd8\xb3\xd8\xaa</NavLink></li>\n                                <li class="breadcrumb-item"><NavLink href="/Products">@Model.CategoryName</NavLink></li>\n                                <li class="breadcrumb-item active" aria-current="page">@Model.BrandName</li>\n                            </ol>\n                        </nav>\n                    </div>\n\n\n@code {\n[Parameter]\npublic Guid Id { get; set; }\nprotected override Task OnParametersSetAsync()\n{\n    return base.OnParametersSetAsync();\n}\nprotected override Task OnAfterRenderAsync(bool firstRender)\n{\n    return base.OnAfterRenderAsync(firstRender);\n}\n\nprotected override bool ShouldRender()\n{\n    return base.ShouldRender();\n}\nprotected override void …
Run Code Online (Sandbox Code Playgroud)

c# blazor blazor-server-side

20
推荐指数
3
解决办法
3万
查看次数

在 Core3.1 中安装 Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation 时,项目必须提供配置错误值

当我在 Web 项目中安装Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation并在启动中添加:

 services.AddMvc().AddRazorRuntimeCompilation();
Run Code Online (Sandbox Code Playgroud)

,项目无法运行,错误为:

项目必须提供配置值

我的.NET-Core版本是3.1

如何解决这个问题?

runtime-compilation razor asp.net-core

2
推荐指数
1
解决办法
1501
查看次数

如何使用客户消息处理错误请求 Web api 核心?

我有类似的问题。\n是否有更简单的方法来处理输入数据类型错误?

\n\n

https://coderethinked.com/customizing-automatic-http-400-error-response-in-asp-net-core-web-apis/

\n\n

我搜索但没有找到答案。

\n\n

更新:

\n\n

我从微软的例子中找到了一个解决方案:\n\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0

\n\n
 return BadRequest (new {message = "Something went wrong"});\n
Run Code Online (Sandbox Code Playgroud)\n\n

但是\n当字段为[必填]时模型时,在运行服务之前会调用错误 400。有没有办法解决句柄模型的 400 错误?

\n

asp.net-core-webapi webapi

0
推荐指数
1
解决办法
2418
查看次数