I try to create complete web apps using ServiceStack.Razor
.
but got problem how to handle authentication in service and page.
handle unauthorized access in service quite easy as we can set authentication attributes. I have config authentication using credentialsAuthProvider and success authenticated using query string to /auth?username=&password
and successfully access secured serviced.
but how to handle unauthorized access to services. currently it return 401 unauthorized access. so when user access the page it only shown blank page.. i have try to setup customhttphandler for unauthorized access to redirect to login page but not success
SetConfig(new EndpointHostConfig {
DebugMode = true,
CustomHttpHandlers = {
{ HttpStatusCode.NotFound, new RazorHandler("/notfound") },
{ HttpStatusCode.Unauthorized, new RazorHandler("/login") },
}
});
Servicestack.razor
allow creating Razor Page like Asp.Net WebPages but there is no sample how to handle authorization in page like using Request.IsAuthenticated
. i have try that, but throw method not exists error.
And how to logout or destroy authentication session
Update: I am using ServiceStack.Razor
with SelfHosting