I am using asp.net identity with EF data first approach. I have hosted my website on appharbor. All of my controllers actions and webapi is working fine except AccountController
. When a user tries to signup it gives the Internal server error
. The details of error is:
My AccountController
is:
[Authorize]
public class AccountController : Controller
{
private Entities db = new Entities();
public AccountController()
: this(new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(new ApplicationDbContext())))
{
}
[HttpPost]
[AllowAnonymous]
public async Task<JsonResult> RegisterUser(string email, string password = "aa")
{
var roleManager = new RoleManager<Microsoft.AspNet.Identity.EntityFramework.IdentityRole>(new RoleStore<IdentityRole>(new ApplicationDbContext()));
if (!roleManager.RoleExists("Admin"))
{
var role = new Microsoft.AspNet.Identity.EntityFramework.IdentityRole();
role.Name = "Admin";
roleManager.Create(role);
}
var ab = email.Split('@');
var user = new ApplicationUser() { UserName = email };
user.Email = ab[0];
UserManager.PasswordValidator = new PasswordValidator
{
RequiredLength = -1
};
var result = await UserManager.CreateAsync(user, password);
if (result.Succeeded)
{
var currentUser = UserManager.FindByName(user.UserName);
var roleresult = UserManager.AddToRole(currentUser.Id, "Admin");
try {
await SignInAsync(user, isPersistent: true);
}
catch (Exception e)
{
string s = e.ToString();
}
var id = user.Id;
var data =await db.AspNetUsers.FindAsync(id);
if (password == "aa")
{
data.IsPasswordSaved = false;
}
else
{
data.IsPasswordSaved = true;
}
db.Entry(data).State = System.Data.Entity.EntityState.Modified;
await db.SaveChangesAsync();
return Json("Done", JsonRequestBehavior.AllowGet);
}
return Json("Error", JsonRequestBehavior.AllowGet);
}
}
I have tried to enable remote connections from this answer. But in SQL Server Configuration Manager
the SQL Server Network Configuration
does not has the option Protocols for SQLEXPRESS
. How can I tackle this issue?