Sunday, 15 March 2015

ServiceStack default Razor view with service -



ServiceStack default Razor view with service -

i want host simple razor page within self host ss app.

i need / path resolve default.cshtml - works out of box.

but need access user auth session within view. guessing need service create model default.cshtml

everything have tried far doesn't work , can't create defaultrequest route / isn't allowed.

anyone got clues need do?

i have tried fall route no luck:

[fallbackroute("/{path*}")] public class fallback { public string path { get; set; } } public class defaultservice : service { public defaultservice () { } public object get(fallback request){ homecoming new httpresult() // #6 { view = "rockstars" // #1 }; } }

your typed userauth session straight accessible in razor views base of operations viewpagebase base.sessionas, e.g:

@{ var session = base.sessionas<customusersession>(); }

you've got access dynamic session handbag base.sessionbag base.isauthenticated determine if user authenticated or not.

fallback route

in order invoke service handle default page need utilize fallback route, e.g:

[fallbackroute("/{path*}")] public class defaultpage { public string path { get; set; } }

a fallback service can used handle every unmatched request including root / page.

servicestack servicestack-razor

No comments:

Post a Comment