简体   繁体   English

asp.net mvc 5尝试在新创建的网站上注册时出错

[英]asp.net mvc 5 error on trying to register at newly created website

fresh os, fresh vs 2015, all i do is create new mvc project with individual authentication and once i try to register it give me that error (i edit nothing, i delete nothing) 新鲜的操作系统,新鲜的vs 2015,我所做的就是用个人身份验证创建新的mvc项目,一旦我尝试注册它就给我错误(我什么都不编辑,我什么也没删除)

Server Error in '/' Application. '/'应用程序中的服务器错误。

The system cannot find the file specified 该系统找不到指定的文件

Description: An unhandled exception occurred during the execution of the current web request. 描述:执行当前Web请求期间发生未处理的异常。 Please review the stack trace for more information about the error and where it originated in the code. 请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息。

Exception Details: System.ComponentModel.Win32Exception: The system cannot find the file specified 异常详细信息:System.ComponentModel.Win32Exception:系统找不到指定的文件

Source Error: 来源错误:

Line 153: { Line 154: var user = new ApplicationUser { UserName = model.Email, Email = model.Email }; 第153行:{第154行:var user = new ApplicationUser {UserName = model.Email,Email = model.Email}; Line 155: var result = await UserManager.CreateAsync(user, model.Password); 第155行:var result = await UserManager.CreateAsync(user,model.Password); Line 156: if (result.Succeeded) Line 157: { 第156行:if(result.Succeeded)第157行:{

Source File: c:\\users****\\documents\\visual studio 2015\\Projects\\WebApplication5\\WebApplication5\\Controllers\\AccountController.cs Line: 155 源文件:c:\\ users **** \\ documents \\ visual studio 2015 \\ Projects \\ WebApplication5 \\ WebApplication5 \\ Controllers \\ AccountController.cs行:155

Stack Trace: 堆栈跟踪:

[Win32Exception (0x80004005): The system cannot find the file specified] [Win32Exception(0x80004005):系统找不到指定的文件]

I've had the same problem, I have found a solution to it .. problem exists in ConnectionString , change it from : 我遇到了同样的问题,我找到了解决方案.. ConnectionString中存在问题,将其更改为:

connectionString="Data Source(LocalDb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\aspnet-WebApplication3-20160303101342.mdf;Initial Catalog=aspnet-WebApplication3-20160303101342;Integrated Security=True"

To : 至 :

  connectionString="Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=YourDatabaseName;Data Source=YourServerName"

And it will work without any other changes 它将无需任何其他更改即可运行

Did you created database using migrations? 您是否使用迁移创建了数据库?

If not, open package manager console in VS(Tools -> NuGet Package Manager -> Package Manager Console) 如果没有,请在VS中打开包管理器控制台(工具 - > NuGet包管理器 - >包管理器控制台)

In command line you have to enable migrations with command. 在命令行中,您必须使用命令启用迁移。

Enable-Migrations -EnableAutomaticMigrations 启用 - 迁移-EnableAutomaticMigrations

after that run command 在那个运行命令之后

Update-Database 更新数据库

and start project. 并开始项目。

https://msdn.microsoft.com/en-us/data/jj591621.aspx https://msdn.microsoft.com/en-us/data/jj591621.aspx

Please follow these tutorial . 请遵循这些教程 You need to enable migration, add first migration with your models and update database. 您需要启用迁移,使用模型添加第一次迁移并更新数据库。

It looks like the tutorial either skipped the database creation part or is behind the latest VS 2013 templates. 看起来教程要么跳过数据库创建部分,要么在最新的VS 2013模板后面。 The Databases is missing when you create a new MVC project. 创建新的MVC项目时,缺少数据库。 In addition, the tutorial register a user via username while the project wants you to use email addresses. 此外,教程在项目要求您使用电子邮件地址时通过用户名注册用户。

Go to package Manager Console 转到包管理器控制台

step 1 Run Below command 步骤1运行以下命令

enable-migrations

Step 2 Run below command 步骤2运行以下命令

add-migrations InitialModel

Step 3 and last run the command 第3步,最后运行命令

update database

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM