开发者

Custom membership provider get current login user

I have little problem, I implement my own membership provider and it works fine. I added userid to articles by this code in controller:

[HttpPost, Authorize, ValidateInput(false)]
        public ActionResult Vytvorit(Article newArticle)
        {
            if(ModelState.IsValid){
                    if(!User.Identity.IsAuthenticated)
                    return View(newArticle);
                newArticle.User.UserID = (int)Membership.GetUser().ProviderUserKey;

            repo.Save(newArticle);
            return RedirectToAction("Zobrazit", new {id=newArticle.ArticleID});
            }
            r开发者_开发问答eturn View(newArticle);
        }

and it was working but now after many changes (in another controllers, models and so) I tried and there is some problem with membership.getuser returns null.

I tried to google it and I found that there might be problem that authenticated user can't be found in the Membership datasource. But I dont know how to fix it.

Thanks

EDIT: MyMembershipProvider


Don't know if it will be much help but I found this to be a useful tutorial when putting together a custom membership provider recently.

http://theintegrity.co.uk/2010/11/asp-net-mvc-2-custom-membership-provider-tutorial-part-1/


I have found this link very useful. writer has wonderful explanation to Custom membership provider. Relay helpful,

http://thekfactor.info/articles

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜