Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 1fa526a

Browse files
View components in asp.net core
1 parent efb124d commit 1fa526a

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using Microsoft.AspNetCore.Mvc;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Threading.Tasks;
6+
7+
namespace Webgentle.BookStore.Components
8+
{
9+
public class TopBooksViewComponent : ViewComponent
10+
{
11+
public async Task<IViewComponentResult> InvokeAsync()
12+
{
13+
return View();
14+
}
15+
}
16+
}
17+

‎Webgentle.BookStore/Webgentle.BookStore/Views/Home/Index.cshtml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616
<div class="py-5 bg-light">
1717
<div class="container">
1818
<h3 class="h3">Top books</h3>
19+
20+
@*@await Component.InvokeAsync("TopBooks")*@
21+
22+
<vc:top-books></vc:top-books>
23+
1924
<div class="row">
2025
<div class="col-md-4">
2126
@*<partial name="_bookThumbnail" model="new BookModel()" />*@
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<h1>Hello from view components</h1>

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /