Comments (6)
Hi there! Which version of Piranha are you using and are you using the new startup or the old (advanced) setup?
from piranha.core.docs.
I'm using 8.x and the assembly way of startup Code.
from piranha.core.docs.
We will add a documentation section about this.
from piranha.core.docs.
But as a preview.. If your web is built from the templates, you should add your own PageModel instead of using SinglePageModel<MyPage>
. Like so
MyPage.cshtml
@page "~/myroute"
@model MyPageModel
MyPage.cshtml.cs
using Microsoft.AspNetCore.Authorization;
using Piranha;
using Piranha.AspNetCore.Models;
using Piranha.AspNetCore.Services;
[Authorize(Policy = "MyPolicyName")]
public class MyPageModel : SinglePageModel<MyPage>
{
public MyPageModel(IApi api, IModelLoader loader) : base(api, loader) { }
}
This way you can use the AuthorizeAttribute
to specify exactly who should have access to the page. It is not possible to reuse "views" with authorization attributes in the way you can with MVC as in MVC the controller action is called first and decides what view to use. In Razor Pages the "view" is called first and then tells which model to use.
Best regards
from piranha.core.docs.
Oh @tidyui, thank you so much! You won't believe it.
I missed the '~' in the 'page' route. :-/ Sorry for wasting your time - but a section in the docs would be nice.
from piranha.core.docs.
We have new features for this is 8.1, check out the docs section for this!
from piranha.core.docs.
Related Issues (20)
- CMSController.cs is missing HOT 2
- How do we create a custom archive with custom posts
- The lack of any serious auth documentation has become an issue.
- Add "author" to archive posts HOT 1
- Complete example of creating a new pagetype/archivetype HOT 1
- Documentation for custom data layer HOT 2
- Creating Module but HeaderBlock does not exist.
- Where can I set up Chinese? HOT 1
- SimpleModule not found
- Docs error HOT 1
- Exception on custom Login request HOT 1
- Using a custom vue file
- Add navigation buttons to docs pages HOT 4
- Renaming content type route 404 error HOT 2
- Running multiple sites with Nginx proxy pass HOT 1
- Calling/api/page/{slug} Getting 500 Error HOT 2
- Remove references to PageTypeRouteAttribute HOT 4
- Improve docs for mixed mode applications HOT 3
- Antiforgery cookie when using external identity provider
- Where would I find the actual API reference ? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from piranha.core.docs.