1. Create ASP.NET (Razor) Web Site
1.1. Select menu File/New/Project...
1.2. Select Razor v3 ASP.NET Web Site (C#)
Save project as WebPagesMovies
1.3. Project creation is done.
Visual Studio 2017 created startup folders and files.
1.3. Open Web.config
The webconfig file contains a connection string to an sdf file
Download the sdf file:
https://archive.org/download/aspnet_tutorial/WebPagesMovies.sdfPut the file into the App_Data folder.
(The App_Data folder might have contained a database file StarterSite.pdf. As for now, ignore it.)
2. Add an ASP.NET (Razor) Web Page
In the Project Explorer, right-click the Project Name item, select Add/Add_New_Item ...
Create an empty Razor C# file with the name Movies.cshtml
Put the following codes:
Run the project
click the Web Launch button
Wait for the web browser to open the page.
Note
To switch the connection to an sql server,edit as follows:
(The sql connection string above connects to the server hosted by somee.com)
Replace the connection name in the script file Movies.cshtml i.e replace the string "WebPagesMovies" with "SQLServerConnectionString" as shown below:
The followings are the sql scripts to create and populate Movies table:
.
No comments:
Post a Comment