I am developing and ASP.NET MVC App as the frontend with the ServiceStack being used for the API and, Authentication and services.
Is there any sample application or docs I could use for inspiration how to integrate the ServiceStack authentication with the ASP.NET [Authorize] attribute?
MVC and ServiceStack Auth are completely different and share no implementation. ServiceStack uses its own
[Authenticate] attribute for its Services which you can also use in your MVC Controllers that inherit
That's exactly what I expected. Thank you.
Is there any sample solution demonstrating this?
The MVC + ServiceStack Example is a simple MVC + ServiceStack App showcasing ServiceStack Auth options, source code is available at:
The docs on MVC + ServiceStack is available at:
I am having problems with getting a session in the _Layout.cshtml to disable menu items which are available only for logged-in user.
If I put in
this creates problems with @Html.ActionLink and "cannot resolve section 'scripts'.
How can _Layout.cshtml get GetSession().IsAuthenticated work without causing problems for ActionLink and scripts?
The ideal solution would be to get the Session via a function, like this ones returns the @Html
protected static new System.Web.Mvc.HtmlHelper Html
ServiceStack Razor pages with ASP.NET MVC Razor pages are completely independent incompatible implementations.
For ASP.NET MVC Razor I recommend passing in the session (or only properties you need from the Session) and return it in the view model.
I am aware that I can choose between SS Razor pages and ASP.NET MVC pages and I am deciding which ones are most helpful for my purposes.
And the ViewModel avenue you recommended works wonderfully!
Thank you so much!