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
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
Post a Comment