简体   繁体   中英

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.

I'm on part 7 now which states the use of the web site administration tool. Well in VS 2013, this tool has been removed. I did find a work around to this while using MS DOS and an external link.

The tutorial in question can be found here: 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

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

Url

//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:

<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.

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. 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.

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.

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.

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.

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.

Here is what to do instead:

Creating the "admin@example.com" user :

  • Run the code for your project and navigate to /Account/Register
  • Create a user using the webpage at /Account/Register. I suggest using the same values suggested by the instructions, username: "admin@example.com", password: "password123!"

Manually adding the "Administrator" group from inside of Visual Studio :

  • From the "View" menu, select "Server Explorer"
  • Expand the "Default Connections" section
  • Expand "DefaultConnection"
  • Expand "Tables"
  • Right Click on "UserProfile", select "Show Table Data"
  • In the "dbo.UserProfile [Data]" window that opens up, make sure that the "UserId" is "1" for the "UserName" of "admin@example.com"

    用户资料

  • In the "Server Explorer", right-click on "webpages_Roles" and select "Show Table Data"
  • 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.

    的角色

  • In the "Server Explorer", right-click on "webpages_UsersInRoles", and select select "Show Table Data"

  • In the "dbo.webpages_UsersInRoles [Data]" window that opens up, enter "1" into both the UserId and RoleId columns.

    UsersInRoles

Once you complete these steps, continue to follow the instructions in the MVC Music Store tutorial.

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. 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. One step at a time I suppose. Important thing is, this particular issue was taken care of.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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