无法注册或登录用户('/'中的服务器错误。) [英] Unable to register or login a user (server error in '/'.)

查看:123
本文介绍了无法注册或登录用户('/'中的服务器错误。)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好!

我创建了一个MVC项目,与我的SQL管理数据库连接。



当我执行我的应用程序时,并尝试登录或创建一个新用户我有一个错误:

'/'中的服务器错误。 

无效的列名称电子邮件。
无效的列名称'EmailConfirmed'。
无效的列名称'PhoneNumber'。
无效的列名称'PhoneNumberConfirmed'。
无效的列名称'TwoFactorEnabled'。
无效的列名'LockoutEndDateUtc'。
无效的列名称'LockoutEnabled'。
无效的列名称'AccessFailedCount'。

描述:执行当前Web请求期间发生未处理的异常。有关错误及其在代码中的起源的详细信息,请参阅堆栈跟踪。

异常详细信息:System.Data.SqlClient.SqlException:无效的列名称'Email'。
无效的列名称'EmailConfirmed'。
无效的列名称'PhoneNumber'。
无效的列名称'PhoneNumberConfirmed'。
无效的列名称'TwoFactorEnabled'。
无效的列名'LockoutEndDateUtc'。
无效的列名称'LockoutEnabled'。
无效的列名称'AccessFailedCount'。

来源错误:


里加46:if(ModelState.IsValid)
里加47:{
里加48:var user =等待UserManager.FindAsync(model.UserName,model.Password);
Riga 49:if(user!= null)
Riga 50:{

File di origine:c:\ Users\\\
ewbreaker\Desktop\Examen Web 2017 \ WebProjet2 \WebProjet2 \Controllers\AccountController.cs里加:48





我缺少什么?



我的尝试:



 // POST:/帐户/登录
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public async任务< ActionResult>登录(LoginViewModel模型,字符串returnUrl)
{
if(ModelState.IsValid)
{
var user = await UserManager.FindAsync(model.UserName,model.Password);
if(user!= null)
{
await SignInAsync(user,model.RememberMe);
返回RedirectToLocal(returnUrl);
}
else
{
ModelState.AddModelError(,无效的用户名或密码。);
}
}

//如果我们到目前为止,有些事情失败,重新显示形式
返回View(模型);
}





在我的 Web.config 上我有:

< connectionStrings> 
< add name =DefaultConnectionconnectionString =Data Source = NEWBREAKER12\SQL2014; Initial Catalog = WebShop; Integrated Security = TrueproviderName =System.Data.SqlClient/>
< appSettings>





在我的模特 - > IdentityModels 我有:

 public ApplicationDbContext()
:base(DefaultConnection,throwIfV1Schema:false)
{
}

解决方案

检查你的数据库:它说它列出的列名不存在于您要访问的表。

首先检查它是该特定版本数据库的正确连接字符串,并根据您的模型检查表定义。


< blockquote>

感谢您回答OriginalGriff; 
我创建了一个新的数据库,再次制作该项目,现在正在运行。
似乎我修改了太多次并且没有识别表格。

:)


Hello!
I have a created an MVC project, connected with my SQL management data base.

When I execute my application, and try to login or create a new user I have an error:

Server Error in '/'.

Invalid column name 'Email'.
Invalid column name 'EmailConfirmed'.
Invalid column name 'PhoneNumber'.
Invalid column name 'PhoneNumberConfirmed'.
Invalid column name 'TwoFactorEnabled'.
Invalid column name 'LockoutEndDateUtc'.
Invalid column name 'LockoutEnabled'.
Invalid column name 'AccessFailedCount'.

Description: An unhandled exception occurred during the execution of the current web request. For more information about the error and where it originated in the code, see the stack trace. 

Exception Details: System.Data.SqlClient.SqlException: Invalid column name 'Email'. 
Invalid column name 'EmailConfirmed'. 
Invalid column name 'PhoneNumber'. 
Invalid column name 'PhoneNumberConfirmed'. 
Invalid column name 'TwoFactorEnabled'. 
Invalid column name 'LockoutEndDateUtc'. 
Invalid column name 'LockoutEnabled'. 
Invalid column name 'AccessFailedCount'. 

Source Error: 


Riga 46:             if (ModelState.IsValid)
Riga 47:             {
Riga 48:                 var user = await UserManager.FindAsync(model.UserName, model.Password);
Riga 49:                 if (user != null)
Riga 50:                 {

File di origine: c:\Users\newbreaker\Desktop\Examen Web 2017\WebProjet2\WebProjet2\Controllers\AccountController.cs    Riga: 48 



What am I missing?

What I have tried:

// POST: /Account/Login
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public async Task<ActionResult> Login(LoginViewModel model, string returnUrl)
{
    if (ModelState.IsValid)
    {
        var user = await UserManager.FindAsync(model.UserName, model.Password);
        if (user != null)
        {
            await SignInAsync(user, model.RememberMe);
            return RedirectToLocal(returnUrl);
        }
        else
        {
            ModelState.AddModelError("", "Invalid username or password.");
        }
    }

    // If we got this far, something failed, redisplay form
    return View(model);
}



On my Web.config I have:

<connectionStrings>
  <add name="DefaultConnection" connectionString="Data Source=NEWBREAKER12\SQL2014;Initial Catalog=WebShop;Integrated Security=True" providerName="System.Data.SqlClient" />
<appSettings>



On my Models -> IdentityModels I have:

public ApplicationDbContext()
    : base("DefaultConnection", throwIfV1Schema: false)
{
}

解决方案

Check your DB: it's saying that the columns names it lists don't exist in the table you are trying to access.
So start by checking it's the right connection string for that specific version of the DB, and check the table definition against your model.


Thank you for you answer OriginalGriff;
I created a new db an made again the project and now is working.
It seem that I have modified too many times and it wasn't recognising the tables.

:)


这篇关于无法注册或登录用户('/'中的服务器错误。)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆