我正在关注 NDC Oslo 的示例应用程序,即以下应用程序: https: //github.com/SteveSandersonMS/presentation-2019-06-NDCOslo/tree/master/demos/MissionControl。这实现了 JWT 作为身份验证和授权。但是,当我尝试将代码的实现复制到服务器端 Blazor 时,当我尝试从本地存储中获取存储的 JWT 令牌(如下所述)时,我收到错误消息”
JavaScript interop calls cannot be issued at this time. This is because the component is being
statically rendererd. When prerendering is enabled, JavaScript interop calls can only be performed
during the OnAfterRenderAsync lifecycle method.
Run Code Online (Sandbox Code Playgroud)
这是我的 blazor 代码
protected override async Task OnInitializedAsync()
{
var token = await TokenProvider.GetTokenAsync();
Branches = await Http.GetJsonAsync<List<BranchDto>>(
"vip/api/lookup/getbranches",
new AuthenticationHeaderValue("Bearer", token));
}
Run Code Online (Sandbox Code Playgroud)
错误来自
public async Task<string> GetTokenAsync()
{
//Code Omitted for brevity …Run Code Online (Sandbox Code Playgroud) 我有以下代码用于 InputSelect
<InputSelect class="form-control form-control form-control-sm"
placeholder="Role"
disabled="@IsReadOnly"
@bind-Value="Model.Role"
@onchange="@RoleChanged">
<option value="Member">Member</option>
<option value="Admin">Admin</option>
<option value="Pioner">Pioneer</option>
<option value="Retailer">Retailer</option>
</InputSelect>
Run Code Online (Sandbox Code Playgroud)
对于代码:
bool ShowCreated;
bool ShowUpdated;
bool IsReadOnly;
string SelectedRole;
public EditForm AccountForm;
public Multi.Dtos.RegistrationDto Model = new Dtos.RegistrationDto() { Role = "Member" };
public void RoleChanged(ChangeEventArgs e)
{
SelectedRole = e.Value.ToString();
Console.WriteLine(e.Value);
}
Run Code Online (Sandbox Code Playgroud)
当我尝试选择一个新项目时,不会调用 RoleChange 函数。有人可以指出这有什么问题吗。正确的值已更改,但未调用事件。
我在Kendo UI网格上遇到了这个奇怪的问题.我有一个可过滤的网格,但它在模态内.但问题是当我过滤一个列(文本列)时,我无法在过滤器文本框中键入.这很奇怪,因为在所有浏览器中它都不起作用.这是我的例子repro
<div class="container">
<h3>Modal Example</h3>
<div>
<a href="#myModal1" role="button" class="btn" data-toggle="modal">Launch Modal</a>
</div>
<!-- Modal -->
<div id="myModal1" class="modal hide" tabindex="-1" role="dialog">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3>Kendo Not working on Modal</h3>
</div>
<div class="modal-body">
<div id="grid" style="height:300px;"></div>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
<button class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
var sharedDataSource = new kendo.data.DataSource({
data: [
{ id: 1, value: 10, item: "Item1" },
{ id: 2, value: 12, item: "Item2" },
{ …Run Code Online (Sandbox Code Playgroud) 我有一个关于SignalR的Caller方法的问题.在hub方法中,我们可以像这样调用客户端函数.
Clients.Caller.addContosoChatMessageToPage(name, message);
Run Code Online (Sandbox Code Playgroud)
但是当我用它从集线器上下文之外调用它时,它找不到或没有实现?像这样..
var context = GlobalHost.ConnectionManager.GetHubContext<MyHub>();
context.Clients.Caller.reportProgress(recordCount,totalCount);
Run Code Online (Sandbox Code Playgroud)
有人可以在这部分启发我,还是有其他方法来实现它..现在我用来实现这一点
var context = GlobalHost.ConnectionManager.GetHubContext<MyHub>();
context.Clients.User(CurrentUser.Usernm).reportProgress(recordCount,totalCount);
Run Code Online (Sandbox Code Playgroud)
但现在我们不是基于声明的身份验证,因此如果记录相同的usernm将会出现问题.
我在从剃刀页面返回部分视图时遇到问题,我的情况是
我有一个局部视图,它是一个表单并且有一个模型。我有 3 个表单驻留在单个剃刀页面上 表单 A 发布 ModelA 表单 B 发布 ModelB 我的问题是,我想在作为剃刀页面的父页面上处理特定的发布事件。我如何返回这个部分视图
OnPostModelA(ModelA model)
{
if(! ModelState.IsValid)
return Partialview("_CreateModelA", model);
}
Run Code Online (Sandbox Code Playgroud)
使用剃刀页面可以做到这一点还是不可能?我只想使用 ajax 返回带有指定模型的局部视图。
我有一个由控制器返回的视图和来自控制器的操作方法,如下所示:
public ActionResult Create()
{
return View()
}
[HttpPost]
public ActionResult Create(FormCollection form)
{
}
Run Code Online (Sandbox Code Playgroud)
我希望它们可以在一个View中完成,如:
@model Models.RegistrationViewModel
@using (Html.BeginForm("Register", "Account", FormMethod.Post, new {@class = "form-horizontal", role = "form"}))
{
@Html.TextboxFor(model.User.Username )
}
Run Code Online (Sandbox Code Playgroud)
但问题是我无法将我的textboxfor绑定到模型属性..如何使用单个视图进行发布并进入我的场景..
我有以下列表,我想从列表中减去Count列表的属性BA
这是样本列表.请注意,我实际上使用的是Linq-To-Entities:
清单A.
List<Leave> defaultLeaves = new List<Leave>()
{
new Leave{ Id = 1 , Count = 7},
new Leave{ Id = 2 , Count = 7},
new Leave{ Id = 3 , Count = 7},
new Leave{ Id = 4 , Count = 3}
};
Run Code Online (Sandbox Code Playgroud)
清单B.
List<Leave> usedLeaves = new List<Leave>()
{
new Leave{ Id = 1 , Count = 1},
new Leave{ Id = 2 , Count = 2}
};
Run Code Online (Sandbox Code Playgroud)
我希望列表的输出是这样A的,B …
我们正在测试我们的应用程序的功能,这里是场景,我们有一个包含500万条记录的表,我们想将它导出到csv,所以我们成功地创建了一个csv编写器类.主要问题是当我们导出整个记录时,我们捕获OOM异常(内存不足异常),当数据超过一百万时,用户可以选择要导出哪些列更难以实现..是否存在没有阻塞过程的任何方式来抓住好东西 什么类型的过程最适合这种情况??? 我应该使用(以及如何)使用后台进程吗?
任何观点(例子)都很受欢迎.谢谢...
c# linq-to-entities entity-framework export-to-csv asp.net-mvc-4
asp.net-core ×3
c# ×3
asp.net ×2
.net ×1
asp.net-mvc ×1
blazor ×1
kendo-grid ×1
kendo-ui ×1
linq ×1
performance ×1
razor ×1
razor-pages ×1
signalr ×1
signalr-hub ×1