简体   繁体   English

MVC音乐商店教程和网站管理工具出现错误

[英]Error with the MVC Music Store Tutorial and the Web Site Administration Tool

I'm currently working through the MVC 4 tutorial on the MVC Music store application. 我目前正在研究MVC音乐商店应用程序上的MVC 4教程。

I'm on part 7 now which states the use of the web site administration tool. 我现在在第7部分中说明了网站管理工具的使用。 Well in VS 2013, this tool has been removed. 在VS 2013中,此工具已被删除。 I did find a work around to this while using MS DOS and an external link. 使用MS DOS和外部链接时,确实找到了解决此问题的方法。

The tutorial in question can be found here: http://www.asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-7 有问题的教程可以在这里找到: http : //www.asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-7

The administration tool work around instructions can be found here: http://forums.asp.net/t/1940600.aspx?Where+is+website+administrator+tools+in+vs+2013+RC 可以在以下位置找到有关管理工具的变通说明: http : //forums.asp.net/t/1940600.aspx?哪里+ is + website + administrator + tools + in + vs + 2013 + RC

Here's my links for the work around to get the administration tool: 这是我获取管理工具的相关链接:

"C:\\Program Files\\IIS Express\\iisexpress.exe" /path:c:\\windows\\Microsoft.NET\\Framework\\v4.0.30319\\ASP.NETWebAdminFiles /vpath:"/asp.netwebadminfiles" /port:6380 /clr:4.0 /ntlm “ C:\\ Program Files \\ IIS Express \\ iisexpress.exe” /path:c:\\windows\\Microsoft.NET\\Framework\\v4.0.30319\\ASP.NETWebAdminFiles /vpath:"/asp.netwebadminfiles“ / port:6380 / clr :4.0 / ntlm

Url 网址

//localhost:6380/asp.netwebadminfiles/default.aspx?applicationPhysicalPath=C:\\Users\\jonathon\\Documents\\Visual Studio 2013\\Projects\\MvcMusicStore\\MvcMusicStore\\&applicationUrl=/ //localhost:6380/asp.netwebadminfiles/default.aspx?applicationPhysicalPath=C:\\Users\\jonathon\\Documents\\Visual Studio 2013 \\ Projects \\ MvcMusicStore \\ MvcMusicStore \\&applicationUrl = /

I'm using my application on Port 6380. My connection string is: 我在端口6380上使用我的应用程序。我的连接字符串是:

<connectionStrings>
    <add name="MusicStoreEntities"
     connectionString="Data Source=|DataDirectory|MvcMusicStore.sdf"
     providerName="System.Data.SqlServerCe.4.0"/>
</connectionStrings>

Now the administration tool comes up, but then I click on the security tab, and I get this error: 现在出现了管理工具,但是随后我单击“安全性”选项卡,然后出现此错误:

There is a problem with your selected data store. 您选择的数据存储有问题。 This can be caused by an invalid server name or credentials, or by insufficient permission. 这可能是由于无效的服务器名称或凭据或权限不足引起的。 It can also be caused by the role manager feature not being enabled. 也可能是由于未启用角色管理器功能引起的。 Click the button below to be redirected to a page where you can choose a new data store. 单击下面的按钮将重定向到页面,您可以在其中选择新的数据存储。

The following message may help in diagnosing the problem: Unable to connect to SQL Server database. 以下消息可能有助于诊断问题:无法连接到SQL Server数据库。

I then click on the provider tab and get this: 然后,我单击提供程序选项卡并获得以下信息:

Use this page to configure how Web site management data such as membership is stored. 使用此页面可以配置如何存储网站管理数据(例如,成员资格)。 You can use a single provider for all the management data for your site or you can specify a different provider for each feature. 您可以将单个提供程序用于站点的所有管理数据,也可以为每个功能指定不同的提供程序。

 Your application is currently configured to use the provider: AspNetSqlProvider 

Select a single provider for all site management data 为所有站点管理数据选择一个提供程序

Select a different provider for each feature (advanced) 为每个功能选择一个不同的提供程序(高级)

I then click on this link from that page: 然后,我从该页面单击此链接:

Select a single provider for all site management data 为所有站点管理数据选择一个提供程序

This brings me to the provider tab with a link to test the provider which is: AspNetSqlProvider. 这使我进入提供程序选项卡,并带有一个测试提供程序的链接:AspNetSqlProvider。 I click test and get this: 我单击测试并得到以下信息:

Could not establish a connection to the database. 无法建立与数据库的连接。

If you have not yet created the SQL Server database, exit the Web Site Administration tool, use the aspnet_regsql command-line utility to create and configure the database, and then return to this tool to set the provider. 如果尚未创建SQL Server数据库,请退出“网站管理”工具,使用aspnet_regsql命令行实用工具创建和配置数据库,然后返回此工具来设置提供程序。

I also looked in my project inside visual studio and noticed that the App_data folder doesn't contain he MDF database files, though if I test the site with the debugger, the current controllers pull up the store data as they are supposed to. 我还查看了Visual Studio内的项目,发现App_data文件夹不包含MDF数据库文件,尽管如果我使用调试器测试该站点,则当前的控制器会按预期方式提取存储数据。

Can anyone help me out here and tell me how to alleviate this issue and move on? 有人可以在这里帮助我,并告诉我如何缓解此问题并继续前进吗?

It is possible to get past the "Part 7: Membership and Authorization" section of the MVC Music Store guide for an MVC 4 project in Visual Studio 2013 using the steps below. 使用下面的步骤,可以跳过Visual Studio 2013中MVC 4项目的MVC音乐商店指南的“第7部分:成员资格和授权”部分。

An important thing to note is that you need to create your application using the "Internet Application" project template , otherwise you'll run into other issues in this section. 需要注意的重要一点是, 您需要使用“ Internet应用程序”项目模板来创建应用程序 ,否则本节将遇到其他问题。

Instead of creating a user with the ASP.NET Configuration website in the section named "Adding an Administrative User with the ASP.NET Configuration site", you'll be creating a user directly from the Music Store application and from inside of Visual Studio. 您将直接从Music Store应用程序和Visual Studio内部创建用户,而不是通过ASP.NET Configuration网站在“使用ASP.NET Configuration网站添加管理用户”部分中创建用户。

Here is what to do instead: 这是替代方法:

Creating the "admin@example.com" user : 创建“ admin@example.com”用户

  • Run the code for your project and navigate to /Account/Register 运行您的项目的代码,然后导航到/ Account / Register
  • Create a user using the webpage at /Account/Register. 使用/ Account / Register上的网页创建用户。 I suggest using the same values suggested by the instructions, username: "admin@example.com", password: "password123!" 我建议使用说明中建议的相同值,用户名:“ admin@example.com”,密码:“ password123!”。

Manually adding the "Administrator" group from inside of Visual Studio : 从Visual Studio内部手动添加“管理员”组

  • From the "View" menu, select "Server Explorer" 从“查看”菜单中,选择“服务器资源管理器”
  • Expand the "Default Connections" section 展开“默认连接”部分
  • Expand "DefaultConnection" 展开“ DefaultConnection”
  • Expand "Tables" 展开“表格”
  • Right Click on "UserProfile", select "Show Table Data" 右键单击“ UserProfile”,选择“显示表数据”
  • In the "dbo.UserProfile [Data]" window that opens up, make sure that the "UserId" is "1" for the "UserName" of "admin@example.com" 在打开的“ dbo.UserProfile [数据]”窗口中,确保“ admin@example.com”的“用户名”的“ UserId”为“ 1”

    用户资料

  • In the "Server Explorer", right-click on "webpages_Roles" and select "Show Table Data" 在“服务器资源管理器”中,右键单击“ webpages_Roles”,然后选择“显示表数据”
  • In the "dbo.webpages_Roles [Data]" window that opens, up for Click on box that contains "NULL" in the "RoleName" column, type "Administrator" into that box. 在打开的“ dbo.webpages_Roles [Data]”窗口中,单击“ RoleName”列中包含“ NULL”的单击框,在该框中键入“ Administrator”。

    的角色

  • In the "Server Explorer", right-click on "webpages_UsersInRoles", and select select "Show Table Data" 在“服务器资源管理器”中,右键单击“ webpages_UsersInRoles”,然后选择“显示表数据”

  • In the "dbo.webpages_UsersInRoles [Data]" window that opens up, enter "1" into both the UserId and RoleId columns. 在打开的“ dbo.webpages_UsersInRoles [数据]”窗口中,在UserId和RoleId列中均输入“ 1”。

    UsersInRoles

Once you complete these steps, continue to follow the instructions in the MVC Music Store tutorial. 完成这些步骤后,请继续按照MVC音乐商店教程中的说明进行操作。

So it seems that I had several issues with connection. 所以看来我在连接方面遇到了几个问题。 One of my biggest was that I was under the impression that SQL Server was installed at the same time that I installed Visual Studio. 我最大的印象之一就是给我留下了在安装Visual Studio的同时安装SQL Server的印象。 I wasn't aware that they came separate and had to be installed separately. 我不知道它们是分开来的,必须分别安装。 Once I installed SQL Server, and got all the ports set up correctly I over came this issue to face new issues. 安装完SQL Server,并正确设置了所有端口后,我遇到了这个问题,要面对新的问题。 One step at a time I suppose. 我想一次迈出一步。 Important thing is, this particular issue was taken care of. 重要的是,已解决了此特定问题。

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

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