所以我注意到在我的 _Host.cshtml 文件中,我在</body>
标签之前有这个脚本
<script src="_framework/blazor.server.js"></script>
Run Code Online (Sandbox Code Playgroud)
我还有一些应该在之后加载的脚本,它们是
<script src="assets/plugins/jquery/jquery.min.js"></script>
<script src="assets/plugins/jquery-ui/jquery-ui.js"></script>
<script src="assets/plugins/popper/popper.js"></script>
<script src="assets/plugins/feather/feather.min.js"></script>
<script src="assets/plugins/bootstrap/js/bootstrap.min.js"></script>
<script src="assets/plugins/typeahead/typeahead.js"></script>
<script src="assets/plugins/typeahead/typeahead-active.js"></script>
<script src="assets/plugins/pace/pace.min.js"></script>
<script src="assets/plugins/slimscroll/jquery.slimscroll.min.js"></script>
<script src="assets/plugins/highlight/highlight.min.js"></script>
<!-- Articles Script -->
<script src="assets/plugins/dataTable/datatables.min.js"></script>
<script src="assets/plugins/summernote/summernote.min.js"></script>
<script src="assets/plugins/bootstrap-tagsinput/bootstrap-tagsinput.js"></script>
<!-- Required Script -->
<script src="assets/js/app.js"></script>
<script src="assets/js/avesta.js"></script>
<script src="assets/js/avesta-customizer.js"></script>
</body>
Run Code Online (Sandbox Code Playgroud)
但是,如果我的顶部有 blazor.js 脚本,我的菜单将无法正常工作,它将停止工作并如下所示。实际上,我点击了很多次,但它并没有像你所看到的那样有动画效果。
但是,如果我将 blazor.server.js 脚本放在底部最后加载,它就可以正常工作,看起来像这样
但是如果我最后加载它,我会在控制台中看到它
这导致我无法做到这一点
<input @bind="@CurrentValue" @oninput="@((e) => { CurrentValue=(string)e.Value;})" @onkeypress="KeyPress" class="form-control" type="text" placeholder="Search" aria-label="Search">
Run Code Online (Sandbox Code Playgroud)
它只是根本没有击中该函数,什么也没有发生,它没有注册它。
所以我正在尝试创建一个使用Identity的 ASP.NET Core 3.1 MVC 应用程序,到目前为止它运行良好。我想向其中添加一个 SQLite 数据库,以便我可以使用 EF (EntityFramework) Code First 存储用户等,这就是我所做的。
我首先使用 SQLite 创建了一个数据库文件,因此我在桌面上的文件夹中有 Database.db 文件。
然后我尝试查找有关如何实现它的文档,但是文档太多了,而且它们都非常不同,所以我无法确定什么是实现它的正确方法。
我从设置我的上下文开始
public class UserContext : IdentityDbContext
{
public DbSet<User> Users { get; set; }
}
public class User : IdentityUser
{
public string CustomerID { get; set; }
public string SubscriptionID { get; set; }
public int IsActive { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
超级简单,然后我将 Startup.cs 中的 ConfigureServices 方法修改为 AddIdentity
public void ConfigureServices(IServiceCollection services)
{
services.AddControllersWithViews();
services.AddIdentity<User, IdentityRole>().AddEntityFrameworkStores<UserContext>();
}
Run Code Online (Sandbox Code Playgroud)
完美,现在我添加了身份。伟大的。 …