小编rgv*_*sar的帖子

ASP.Net-Core中的自定义身份验证

我正在开发一个需要与现有用户数据库集成的Web应用程序.我仍然想使用这些[Authorize]属性,但我不想使用Identity框架.如果我确实想使用Identity框架,我会在startup.cs文件中添加这样的内容:

services.AddIdentity<ApplicationUser, IdentityRole>(options =>
{
    options.Password.RequireNonLetterOrDigit = false;
}).AddEntityFrameworkStores<ApplicationDbContext>()
  .AddDefaultTokenProviders();
Run Code Online (Sandbox Code Playgroud)

我假设我必须在那里添加其他东西,然后创建一些实现特定接口的类?有人能指出我正确的方向吗?我正在使用asp.net 5的RC1.

c# asp.net authentication asp.net-core-mvc asp.net-core

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

最小高度导致填充被忽略

添加min-height到div之后,子元素将在填充之外流动。下一个元素具有height: 100%,我认为这与它有关。

html, body { height: 100%;}
.card {height: 100%;}
.card-header {min-height: 50px;}
.card-block {height: 100%;}
Run Code Online (Sandbox Code Playgroud)
<link data-require="bootstrap@4.1.3" data-semver="4.1.3" rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" />
<script data-require="bootstrap@4.1.3" data-semver="4.1.3" src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>


        <div class="card">
          <div class="card-header">
            <div class="d-flex align-items-center flex-column">
              <div>line 1</div>
              <div>line 2</div>
              <div>line 3</div>
            </div>
          </div>
          <div class="card-block">
            Some other content
          </div>
        </div>
Run Code Online (Sandbox Code Playgroud)

您可以在这个问题中看到问题。如果min-height: 50px仅从card-header类中删除代码,则可以看到它变得更大了。我想要一个最小的高度,但是仍然要尊重填充。我真的不明白这里发生了什么。

html css

6
推荐指数
1
解决办法
60
查看次数

在ASP.NET Core中使用授权属性和自定义Cookie身份验证

我在Startup.cs中有以下代码:

public void ConfigureServices(IServiceCollection services)
{
    //Other middleware
    services.AddAuthentication(options =>
    {
        options.SignInScheme = "MyAuthenticationScheme";
    });

    services.AddAuthorization();
}

public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
    //Other configurations.
    app.UseCookieAuthentication(options =>
    {
        options.AuthenticationScheme = "MyAuthenticationScheme";
        options.LoginPath = new PathString("/signin/");
        options.AccessDeniedPath = new PathString("/signin/");
        options.AutomaticAuthenticate = true;
    });
}
Run Code Online (Sandbox Code Playgroud)

然后,出于测试目的,我有一个登录页面,您只需单击一个按钮,它就会回复自身,并在控制器中显示此代码.

SignInController.cs

public IActionResult Index()
{
    return View();
}

[HttpPost]
[AllowAnonymous]
public async Task<IActionResult> Index(SignInViewModel model)
{
    List<Claim> claimList = new List<Claim>();
    claimList.Add(new Claim("Admin", "true"));
    ClaimsIdentity identity = new ClaimsIdentity(claimList);
    ClaimsPrincipal principal = …
Run Code Online (Sandbox Code Playgroud)

c# asp.net authentication asp.net-core-mvc asp.net-core

4
推荐指数
1
解决办法
3866
查看次数