Click here to Skip to main content
15,890,506 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I just started ASP.NET, been looking around for the solution, but nothing has helped so far. The current method I'm using was found on an tutorial, which seemingly was working, except it isn't working for me.

Here's my code;

Razor
@{

Layout = "~/_Layout.cshtml";

var username = string.Empty;

var name = string.Empty;
var surname = string.Empty;
var email = string.Empty;
var address = string.Empty;
var phonenumber = string.Empty;
var password = string.Empty;

var confirmPassword = string.Empty;
var errorMessage = string.Empty;

if (!IsPost) {
    if (WebSecurity.IsAuthenticated) {
        errorMessage = "You are already logged in.";
    }
} else {
    username = Request["username"];
    password = Request["password"];

    name = Request["name"];
    surname = Request["surname"];
    email = Request["email"];
    address = Request["address"];
    phonenumber = Request["phonenumber"];

    confirmPassword = Request["confirmPassword"];

    if (password != confirmPassword) {
        errorMessage = "Passwords do not match.";
    } else {
        if (WebSecurity.UserExists(username)) {
            errorMessage = string.Format("User '{0}' already exists.", username);
        } else {

            var userInfo = new{name =name , surname = surname, email = email, address = address, phonenumber = phonenumber};
            WebSecurity.CreateUserAndAccount(username, password, userInfo  ,false);
            WebSecurity.Login(username, password, true);
            errorMessage = string.Format("{0} was created.", username);
        }
    }

}
} 


Right at the bottom at the WebSecurity.CreateUserAndAccount no mater what I try, I fail to run the code successfully, currently I'm getting the following error: The column name is not valid. [ Node name (if any) = ,Column name = name ]

I tried using propertyValues: new{Name = name , Surname = surname, Email = email, Address = address, PhoneNumber = phonenumber}; but it didn't work either, I'm receiving the following error: Named argument specifications must appear after all fixed arguments have been specified.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900