小编ACG*_*ACG的帖子

如何使用AspNet.Identity使用Asp.Net MVC5 RTM位登录/验证用户?

道歉并提前感谢您提出这个问题!我还是SO的新手.

我一直在使用MVC5,EF6和VS 2013开发Web应用程序.

一旦发布,我花了一些时间升级到RC位.感谢所有伟大的帖子:例如.解耦Microsoft.AspNet.Identity.*并将asp.net MVC从5.0.0-beta2更新到5.0.0-rc1!

在我无限的智慧中,我决定转向@Hao Kung在这里发布的RTM位:我如何能够及早访问即将到来的Asp.Net Identity变化?.我认为当我们最终收到RTM版本时,我会省去麻烦并且不会太落后.

这可能是一场噩梦,或者我只是完全遗漏了某些东西(或两者兼而有之),因为我无法弄清楚曾经使用RC1的基本任务.

虽然我似乎是通过控制器登录用户(Asp.Net Identity RTM版本中的Microsoft.AspNet.Identity.Owin.AuthenticationManager在哪里?)...我的WindowsIdentity始终为空,在我调用SignIn后未经过身份验证.正确填充了user和claimIdentity对象.

这是我调用的操作方法(为了完整性将属性移动到局部变量):

[HttpPost, AllowAnonymous, ValidateAntiForgeryToken]
public virtual async Task<ActionResult> Login(LoginViewModel model, string returnUrl)
{
    if (ModelState.IsValid) {
        var userManager = new UserManager<EtdsUser>(new UserStore<EtdsUser>(new EtdsContext()));
        var user = userManager.Find(model.UserName, model.Password);
        if (user != null) {
            var authenticationManager = HttpContext.GetOwinContext().Authentication;
            authenticationManager.SignOut(new[] {DefaultAuthenticationTypes.ApplicationCookie, DefaultAuthenticationTypes.ExternalCookie, DefaultAuthenticationTypes.ExternalBearer});
            var claimsIdentity = await userManager.CreateIdentityAsync(user, DefaultAuthenticationTypes.ApplicationCookie);
            authenticationManager.SignIn(new AuthenticationProperties { IsPersistent = model.RememberMe}, claimsIdentity);
            return RedirectToLocal(returnUrl);
        }
    }
    ModelState.AddModelError("", "The …
Run Code Online (Sandbox Code Playgroud)

c# owin visual-studio-2013 asp.net-mvc-5 asp.net-identity

47
推荐指数
1
解决办法
8万
查看次数

垂直对齐Bootstrap 3列的内容

经过四年的中断后回到网络开发之后,我很难将bootstrap 3列的内容与下一列垂直对齐.我一直试着搜索这个网站以及一般的通用搜索,并且没有找到正确的解决方案...或者我的搜索条件很差.

在下面的HTML/CSS中,我想垂直居中左侧列中的"页面标题"文本.我想在使用Bootstrap 3 CSS时尽可能简洁地保持HTML和CSS的简洁,所以我想我完全错过了一些简单的东西.

HTML

<div class="row page-header-box">
<div class="col-md-2 col-sm-2 col-xs-3 page-header-title">Page Title</div>
<div class="col-md-10 col-sm-10 col-xs-9 page-header-seperator">
    <div class="page-header-description"><small>Standard Text Description</small></div>
    <div class="page-header-alt"><small>Additional Text Description</small></div>
</div>
Run Code Online (Sandbox Code Playgroud)

CSS

    .page-header-box {
        background-color:#3D3D3D;
        border-bottom:5px solid #b3b5b8;
        margin-bottom:10px;
    }
    .page-header-title { color:#f79239;text-align:right;vertical-align:middle;margin:10px 0; }
    .page-header-seperator { border-left:5px solid #4e2f91;margin:10px 0; }
    .page-header-description { color:#febe10; }
    .page-header-alt { margin-top:5px;color:#0093b2; }
    

这是一个jsFiddle ... http://jsfiddle.net/E6LcY/8/

这是我发布过的少数几次之一,因此指向正确的方向会很棒.

css vertical-alignment css3 twitter-bootstrap-3

13
推荐指数
1
解决办法
3万
查看次数