没有合适的资源?快使用搜索试试~ 我知道了~
首页ASP.NET Core 2.0 MVC Razor Pages for Beginners
资源详情
资源评论
资源推荐

ASP.NET Core 2.0
MVC & Razor Pages
for Beginners
How to Build a Video Course Website

ASP.NET Core 2.0 MVC For Beginners - How to build a Video Course Website
Overview .............................................................................................................................. 1
Setup ................................................................................................................................ 2
Book Version .................................................................................................................... 2
Other Books by the Author.............................................................................................. 3
Video Courses Produced by the Author .......................................................................... 4
MVC 5 – How to Build a Membership Website (video course) ................................... 4
Store Secret Data in .NET Core Web App with Azure Key Vault (video course) .......... 4
Source Code ..................................................................................................................... 4
Disclaimer – Who Is This Book for? ................................................................................. 5
Rights ............................................................................................................................... 5
About the Author ............................................................................................................ 5
Part 1: ASP.NET Core 2.0 MVC Your First Application ......................................................... 7
1. Your First ASP.NET Core Application ............................................................................... 9
The Project Layout and the File System .................................................................... 11
Important Files .......................................................................................................... 12
Compiling the Solution .............................................................................................. 14
The Startup.cs File ..................................................................................................... 15
Adding a Configuration Service ..................................................................................... 16
Creating a Service .......................................................................................................... 18
Example ..................................................................................................................... 19
Adding the IMessageService Interface .................................................................. 20
Adding the HardcodedMessageService Class ........................................................ 20
Configure and Use the HardcodedMessageService Class ..................................... 21
Add and Use the ConfigurationMessageService Class .......................................... 23
Summary ........................................................................................................................ 25
2. Middleware ................................................................................................................... 27

ASP.NET Core 2.0 MVC & Razor Pages for Beginners
How Does Middleware Work? ...................................................................................... 27
IApplicationBuilder ........................................................................................................ 28
Handling Exceptions .................................................................................................. 30
Serving Up Static Files ................................................................................................... 33
Setting Up ASP.NET MVC ............................................................................................... 34
Summary ........................................................................................................................ 37
3. MVC Controllers ............................................................................................................ 39
Routing .......................................................................................................................... 40
Convention-Based Routing ........................................................................................ 41
Implement Routing ................................................................................................ 41
Adding Another Controller .................................................................................... 42
Attribute Routing ....................................................................................................... 43
IActionResult ................................................................................................................. 47
Implementing ContentResult .................................................................................... 47
Using a Model Class and ObjectResult ...................................................................... 48
Introduction to Views .................................................................................................... 50
A View with a Data Collection ....................................................................................... 52
Adding a Data Service .................................................................................................... 54
Summary ........................................................................................................................ 59
4. Models ........................................................................................................................... 61
View Model Example ..................................................................................................... 62
Changing the Folder Structure .................................................................................. 62
Adding the View Model ............................................................................................. 62
Using the View Model ............................................................................................... 63
Adding a Details View .................................................................................................... 64
Adding a Create View .................................................................................................... 69
Refactoring the Application ....................................................................................... 70

ASP.NET Core 2.0 MVC & Razor Pages for Beginners
Adding the HTTP GET Create Action and the Create View ........................................ 72
Adding the VideoEditViewModel Class ..................................................................... 75
Adding the HTTP POST Create Action ........................................................................ 76
Data Annotations ........................................................................................................... 81
Preparing the Create View for Validation ................................................................. 82
Adding Validation to the Create View ................................................................... 82
Validating the Model on the Server .......................................................................... 83
Adding Data Annotations in the Video Entity and VideoEditViewModel Class ......... 84
Summary ........................................................................................................................ 87
5. Entity Framework .......................................................................................................... 89
Adding the VideoDbContext Class ............................................................................. 89
Configuration in the Startup Class ............................................................................. 91
Adding the Initial Migration and Creating the Database ........................................... 93
Adding the SqlVideoData Service Component .............................................................. 95
Implementing the SqlVideoData Service Component Class ...................................... 95
Summary ........................................................................................................................ 99
6. Razor Views ................................................................................................................. 101
Layout Views ................................................................................................................ 101
Adding the _Layout View ......................................................................................... 102
Altering the Content Views ..................................................................................... 102
The _ViewStart file ...................................................................................................... 106
The _ViewImports file ................................................................................................. 107
Tag Helpers .................................................................................................................. 108
Altering the Index View ........................................................................................... 109
Adding an Edit View and Its Actions ........................................................................ 111
Refactoring the IVideoData Service ......................................................................... 113
Partial Views ................................................................................................................ 117

ASP.NET Core 2.0 MVC & Razor Pages for Beginners
View Components ....................................................................................................... 120
Adding a View Component for the IMessageService Service .................................. 120
Summary ...................................................................................................................... 123
7. Forms Authentication .................................................................................................. 125
Adding the Authorize and AlowAnonymous Attributes .............................................. 126
Configuring the Identity Framework ........................................................................... 127
Creating the AspNet Identity Database Tables ........................................................... 129
User Registration ......................................................................................................... 130
Login and Logout ......................................................................................................... 137
Adding the _Login Partial View................................................................................ 137
Adding the Logout Action ........................................................................................ 140
Adding the LoginViewModel Class .......................................................................... 141
Adding the HTTP GET Login Action .......................................................................... 142
Adding the HTTP POST Login Action ........................................................................ 142
Adding the Login View ............................................................................................. 144
Summary ...................................................................................................................... 147
8. Front-End Frameworks ................................................................................................ 149
Installing Bower and the Frameworks ......................................................................... 149
Styling with Bootstrap ................................................................................................. 152
Adding a Navigation Bar .......................................................................................... 153
Styling the Index View ............................................................................................. 155
Adding Client-Side Validation ...................................................................................... 157
Summary ...................................................................................................................... 159
Part 2: MVC How to Build a Video Course Website ....................................................... 161
9. The Use Case................................................................................................................ 163
Introduction ................................................................................................................. 163
The Use Case ............................................................................................................... 163
剩余527页未读,继续阅读
















安全验证
文档复制为VIP权益,开通VIP直接复制

评论0