Accessing Session in the ServiceStack Razor View -
i trying access session inside servicestack razor view (partial). in case trying render our menu exists in session.
@(new htmlstring(this.sessionas<customusersession>().menuhtmlstring))
i error:
response status
error code nullreferenceexception message object reference not set instance of object. stack trace [bopbasicinfo1vm: 1/31/2014 9:46:45 pm]: [request: {quotenumber:1,agencyid:0,errors:[],isvalid:false}] system.nullreferenceexception: object reference not set instance of object. @ asp._bopbasicinfo1vm.execute() @ servicestack.razor.viewpage
1.writeto(streamwriter writer) @ servicestack.razor.managers.razorpageresolver.executerazorpagewithlayout(irequest httpreq, iresponse httpres, object model, irazorview page, func
1 layout) @ servicestack.razor.managers.razorpageresolver.resolveandexecuterazorpage(irequest httpreq, iresponse httpres, object model, razorpage razorpage) @ servicestack.razor.managers.razorpageresolver.processrequest(irequest httpreq, iresponse httpres, object dto) @ servicestack.formats.htmlformat.<>c_displayclass2.b__0(iviewengine x) @ system.linq.enumerable.any[tsource](ienumerable1 source, func
2 predicate) @ servicestack.formats.htmlformat.serializetostream(irequest request, object response, iresponse httpres)
am trying access session correctly? ideas why failing?
as far know there no break point/debug support in ss razor views, has changed latest version v4.0.8.0+?
the issue turned out
@(new htmlstring())
instead of
this.sessionas<customusersession>().menuhtmlstring
the way figured out creating static method on class , passing "this" debug.
public static htmlstring getmenu(servicestack.razor.viewpage page) { return new htmlstring(page.sessionas<fmic.dtos.entities.customusersession>().menuhtmlstring); }
and calling view.
@(viewpageextensions.getmenu(this))
i add comment demis (mythz) servicestack forums
to debugging call own method razor views can put breakpoint , inspect values passed in.
you should able debug v4.09 source code using source symbols published nuget, instructions: https://github.com/servicestack/servicestack/wiki/debugging#wiki-debugging-source-symbols-in-nuget-packages
Comments
Post a Comment