Skip to main content
Membership.CreateUser(Loginid, Password, Emailid);

Error : Object Reference not to set an object


Solutions:
1)Continue to rely on SPClaimsAuthMembershipProvider and obtaining HttpContext.Current

Just instantiate the HttContext.Current If it is null:


if (HttpContext.Current == null)
{
HttpRequest request = new HttpRequest(String.Empty, sp_web.Url, String.Empty);
HttpContext.Current = new HttpContext(request, new HttpResponse(new StringWriter()));
}

If you instantiated new HttpContext, it would be good to reset it at the end of your methods back to null. Just make sure this happens only if HttpContext.Current was null at the beginning.

2)Working with the SqlMembershipProvider and forgetting about HttpContext.Current issue

What we need is to get the SqlMembershipProvider from registered providers and to start using it.
SqlMembershipProvider sqlMembershipProvider = (SqlMembershipProvider)Membership.Providers["FBAMembershipProvider"];

Bear in mind that you should put the name as it is in your web.config file.





http://kbochevski.blogspot.in/2011/01/accessing-membership-database-inside.html

Comments

Popular posts from this blog

SharePoint Farm Installation

Windows Cluster : http://technet.microsoft.com/en-us/library/bb727114.aspx http://blogs.msdn.com/b/clustering/archive/2008/01/18/7151154.aspx SQL Cluster : http://clusteringformeremortals.com/2009/10/07/step-by-step-configuring-a-2-node-multi-site-cluster-on-windows-server-2008-r2-%E2%80%93-part-3/ Network Load Balancing http://www.jppinto.com/2009/05/install-and-configure-wlbs-nlb-on-windows-server-2008/ SharePoint 2010 Farm Installation http://www.khamis.net/blog/Lists/Posts/Post.aspx?ID=48