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 9c27c2b

Browse files
Authorize attribute in asp.net core
1 parent dfda48a commit 9c27c2b

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

‎Webgentle.BookStore/Webgentle.BookStore/Controllers/BookController.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.IO;
44
using System.Linq;
55
using System.Threading.Tasks;
6+
using Microsoft.AspNetCore.Authorization;
67
using Microsoft.AspNetCore.Hosting;
78
using Microsoft.AspNetCore.Http;
89
using Microsoft.AspNetCore.Mvc;
@@ -48,6 +49,7 @@ public List<BookModel> SearchBooks(string bookName, string authorName)
4849
return _bookRepository.SearchBook(bookName, authorName);
4950
}
5051

52+
[Authorize]
5153
public async Task<ViewResult> AddNewBook(bool isSuccess = false, int bookId = 0)
5254
{
5355
var model = new BookModel();

‎Webgentle.BookStore/Webgentle.BookStore/Startup.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
7979
app.UseRouting();
8080

8181
app.UseAuthentication();
82-
82+
app.UseAuthorization();
8383
app.UseEndpoints(endpoints =>
8484
{
8585
endpoints.MapDefaultControllerRoute();

0 commit comments

Comments
(0)

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