error in attempt registration user.

Nov 17, 2013 at 6:53 PM
Edited Nov 17, 2013 at 8:39 PM
I cannot create new account

I try describe what happened.

AccountController, action name - register...

method return new User
MembershipCreateStatus createStatus = this.membershipService.CreateUser(model.Username, model.Password, model.EmailAddress);
but next method return null
MembershipUser u = this.membershipService.GetUser(model.Username);
The method below return null...
public override MembershipUser GetUser(String qwerty, Boolean false) {
            MembershipUser user = this.ActualProvider.GetUser(qwerty, false);
            // Did we get a user, and is he/she online?
            if (user != null && userIsOnline) {
                // Update lastvisit!
            return user;
and next method is failed.
String code = String.Format("{1}#|#{0}#|#{2}", u.UserName, u.Email, u.ProviderUserKey);
error message "Object reference not set to an instance of an object."
I look CreateUser and it method has SaveChanges but why GetUser retnurn is nothing.
in database is nothing too
Nov 19, 2013 at 5:40 AM
"in database is nothing too" ? No tables, or just no new user ?

What is it you're trying to do? Is this your own code, or is this the MVC Forum code in the /area/forum/controllers/accountcontroller.cs class?
Nov 19, 2013 at 7:04 AM
Edited Nov 19, 2013 at 7:16 AM
database's tables is exsist. This code from MVCforum I try just using it. Yes AccountController
but more accurately GetUser method and in depth
this.ActualProvider.GetUser(userName, false)  // return null
return null. But before method CreateUser return new user - status "success".
I think can create user but dont save to database
Nov 19, 2013 at 5:10 PM
Do you use the code in an application where MVC Forum is initialized? For any of this code to work, it's very important that MVC's dependency resolver can resolve the interfaces needed for accessing the database (IContext, IRepository<User>, etc).

If you, in your code, get a object (not null) back when calling DependencyResolver.Current.GetService<IContext>() and the same for IRepository<User> everything should be okay.
Nov 19, 2013 at 8:47 PM
Edited Nov 19, 2013 at 10:13 PM
I am so sorry. I using only default code in MVCForum. And only update some incorrect dll (WebActivator,ninject) for good building. I think I have mistake. but I dont know where. In MVCForum I changed only connection string
but database is created with all tables and default topics in forum.

part of web config with settings
         <add name="mvcForum.DataProvider.MainDB" connectionString="Server=WIN-KUCGB4CARCJ;Database=mvcforum;User ID=Alex;password=12345;Integrated Security=true" providerName="System.Data.SqlClient" />
     <membership defaultProvider="ProviderWrapper">
        <clear />
        <add name="ProviderWrapper" type="mvcForum.Web.Providers.MembershipProviderWrapper" WrappedProvider="TheRealProvider" />
        <add name="TheRealProvider" type="MVCBootstrap.Web.Security.SimpleMembershipProvider" applicationName="mvcForum" minRequiredPasswordLength="6" userIsOnlineTimeWindow="10" />
    <roleManager enabled="true" defaultProvider="SimpleProvider">
        <clear />
        <add name="SimpleProvider" type="MVCBootstrap.Web.Security.SimpleRoleProvider" />
I public video on youtube by duration 0:42 seconds

Nov 24, 2013 at 6:59 PM
Today I install VS 2013 and it can update all bad reference automaticaly with nuget. And now is all right. Thanks and sorry for time.
Marked as answer by xxarchexx on 11/24/2013 at 12:45 PM