我首先在我的UWP和.NET Standard应用程序中使用Entity Framework Core 2.0 for Sqlite代码.我的模型有一个主键整数类型的实体,根据SQLite文档应该作为自动增量.但实际上,Identity列的每一行都将0作为值.请帮助,因为我找不到与此问题相关的帮助材料.
这是我的财产,没有任何数据注释.
public Int32 No { get; set; }
我使用了流畅的API
modelBuilder.Entity<TurnosGeneral>()
.HasKey(c => new { c.No, c.Cod_Turno });
Run Code Online (Sandbox Code Playgroud)
并在此处插入值
db.TurnosGenerals.Add(new TurnosGeneral { Cod_Turno = numeroTurnoTextBlock.Text });
Run Code Online (Sandbox Code Playgroud)
db.SaveChanges();
插入的每一行c.No为0.
c# sqlite auto-increment entity-framework-core .net-standard-2.0
我是ASP .NET Core 2.1的初学者,正在开发使用ASP .NET Core 2.1和个人身份验证的项目.我想将我的登录页面作为我的默认路由而不是Home/Index:
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
Run Code Online (Sandbox Code Playgroud)
任何帮助如何将其更改为ASP .NET Core 2.1,因为Login现在用作剃刀页面而不是MVC Action View.
c# asp.net-mvc-routing asp.net-identity razor-pages asp.net-core-2.1
我在每次迁移时都会遇到种子角色的奇怪行为。无论您做了什么更改,迁移都会删除种子角色并再次插入它们。当项目中没有进行任何修改时,将创建下面给出的迁移。
所有其他模型均已正确播种,并且仅在修改它们时才考虑迁移。
我将 ASP .NET Core 2.1 与个人身份验证一起使用
用于播种的 DbContext 类
public class ApplicationDbContext : IdentityDbContext
{
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
: base(options)
{
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
#region Seed-Roles
modelBuilder.Entity<IdentityRole>().HasData(new IdentityRole { Name = "SuperAdmin", NormalizedName = "SuperAdmin".ToUpper() });
modelBuilder.Entity<IdentityRole>().HasData(new IdentityRole { Name = "Owner", NormalizedName = "Owner".ToUpper() });
modelBuilder.Entity<IdentityRole>().HasData(new IdentityRole { Name = "Admin", NormalizedName = "Admin".ToUpper() });
modelBuilder.Entity<IdentityRole>().HasData(new IdentityRole { Name = "Tester", NormalizedName = "Tester".ToUpper() });
modelBuilder.Entity<IdentityRole>().HasData(new IdentityRole { Name = "User", NormalizedName …Run Code Online (Sandbox Code Playgroud) c# asp.net-core-identity asp.net-core-2.1 ef-core-2.1 entity-framework-migrations
仅当我在共享托管上部署 ASP .NET Core 2.1 Web 应用程序时,才会出现此问题。我将 Azure Key Vault 与 PersistKeysToFileSystem 结合使用。
Web 应用程序在我的开发计算机上以及使用 PersistKeysToFileSystem 的带或不带 Azure Key Vault 的 Azure 应用程序上运行良好。
fail: Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingProvider[48]
An error occurred while reading the key ring.
System.Net.Http.HttpRequestException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of …
c# key-management azure asp.net-core-identity asp.net-core-2.1
有什么方法可以从本地驱动器在 asp.net core 2 (razor) Web 应用程序中显示图像?
我想要这样做的原因是我正在开发一个游戏服务器,其中包含一个游戏服务器和两个网站(前端和管理面板),所有这些都需要访问上述图像,在本例中是个人资料图像这就是为什么我没有将这些图像放在 wwwroot 文件夹中。
示例图片地址:“C:\game_data\avatars\default.png”
c# asp.net-core asp.net-core-2.0 razor-pages asp.net-core-2.2
我正在为我的 Web 项目使用 ASP .NET Core 3.1 个人身份验证模板。我正在尝试集成 LinkedIn 外部登录,但不知道如何正确执行。
我使用以下链接寻求帮助: OAuth LinkedIn Integration
这是我的代码:
services.AddAuthentication()
.AddOAuth("LinkedIn", "LinkedIn", options =>
{
IConfigurationSection linkedinAuthNSection =
Configuration.GetSection("Authentication:Linkedin");
options.ClientId = linkedinAuthNSection["ClientId"];
options.ClientSecret = linkedinAuthNSection["ClientSecret"];
options.CallbackPath = new PathString("/signin-linkedin");
options.AuthorizationEndpoint = "https://www.linkedin.com/oauth/v2/authorization";
options.TokenEndpoint = "https://www.linkedin.com/oauth/v2/accessToken";
options.UserInformationEndpoint = "https://api.linkedin.com/v1/people/~:(id,formatted-name,email-address,picture-url)";
options.Scope.Add("r_liteprofile");
options.Scope.Add("r_emailaddress");
options.Scope.Add("w_member_social");
});
Run Code Online (Sandbox Code Playgroud)
但是我在OnGetCallbackAsync处理程序中遇到错误:
var info = await _signInManager.GetExternalLoginInfoAsync();
Run Code Online (Sandbox Code Playgroud)
info接收到的值null
c# asp.net-core-identity asp.net-core-2.1 .net-core-3.1 asp.net-core-3.1
c# ×6
razor-pages ×2
asp.net-core ×1
azure ×1
ef-core-2.1 ×1
entity-framework-migrations ×1
sqlite ×1