Home Microsoft.AspNetCore.Identity authorization or authentification with razor pages
Reply: 0

Microsoft.AspNetCore.Identity authorization or authentification with razor pages

user1062
1#
user1062 Published in May 21, 2018, 6:43 pm

I try to use Microsoft.AspNetCore.Identity with pages. Can I do it or I must choose Razor Pages authorization conventions like in https://docs.microsoft.com/en-us/aspnet/core/security/authorization/razor-pages-authorization? I `see

services.AddMvc()


  .AddRazorPagesOptions(options =>
    {
    options.Conventions.AuthorizeFolder("/Account/Manage");
    options.Conventions.AuthorizePage("/Account/Logout");
});`

I have .cshtml file with

  @model Proj_s.Models.AccountViewModels.RegisterViewModel
    @{
        ViewData["Title"] = "Register";
    }
    <h2>@ViewData["Title"]</h2>
    .......
    @section Scripts {
        @await Html.PartialAsync("_ValidationScriptsPartial")
    }

I replace @page @model Proj_s.Pages.Projects.DetailsModelwith @model Proj_s.Models.AccountViewModels.RegisterViewModel

What the best way to add authentification or authorization to existing razor page that does not contain this?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.309221 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO