
[英]/signalr/hubs 404 not found when deployed to local IIS server, works on IIS express + signalr 1.0
[英]Blazor server app with IJSRuntime works in Development but not when deployed to IIS server
我有标准的 blazor 计数器演示应用程序,它成功地向 IIS 10 发送。
当我添加 IJSRuntime 代码以访问 Bazor 组件中的 JS 时,当我使用 IIS 而不是在开发模式下使用 IIS express 时出现错误。
有人可以帮忙吗?
@page "/counter"
<h1>Counter</h1>
<p>Current count: @currentCount</p>
<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>
@code {
private int currentCount = 0;
[Inject] IJSRuntime JSRuntime { get; set; }
IJSObjectReference module;
private void IncrementCount()
{
currentCount++;
}
protected override async Task OnAfterRenderAsync( bool firstTime )
{
if (firstTime)
{
module = await JSRuntime.InvokeAsync<IJSObjectReference>("import", "/counter.js");
await module.InvokeVoidAsync("ShowPrompt", "Prompt");
}
}
}
//// 计数器.js
export function ShowPrompt(message) {
prompt(message)
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.