Is there anyway to get to Session from there, or can it be modified to do so?
Thanks.
Dan
8 Answers, 1 is accepted
Using session variables in an MVC project is not recommended.
If you still want to work with the ASP.NET Session, searching the web points to settings that can allow you to access it in Web API controllers:
- Accessing Session Using ASP.NET Web API - stackoverflow;
- Access Session in Web API (MVC) - private blog post;
Regards,
Stef
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
Thanks. Dan
Here is the API that is made just before the 3rd Resolve call.
"/api/reports/clients/02b97711ca4/instances/38dfedd32eb/documents/94eb4a5f91400c4290b7eb/info"
Think I found a way. The main reason I was trying to gain access to the session was to set the connection string dynamically by using the session to figure out where I should be connected from within the Resolve function. In the following link I realized I can do this via a report parameter. I am going to try that. So that from my MVC side of code can provide the connection string since it should already be within the context of my session and I don't have to rely on Web API through Telerik to provide my access to it.
https://docs.telerik.com/reporting/knowledge-base/how-to-pass-connectionstring-to-report-dynamically-through-report-parameter
Setting the connection string dynamically through a report parameter is the approach we recommend.
For the HttpContext-related issues you can check How to use information from HttpContext in Custom Report Resolver KB article, where we have explained the reason for HttpContext *not* to be available in report rendering thread, and the workaround to use the information from it if necessary.
Regards,
Todor
Progress Telerik
Indeed, if the resolver is created in the static constructor of the ReportsController class (our default implementation), it will be reused with all clients until the application gets restarted and some report information from one session may be accessible by another.
Note that the report resolver may be created also in the normal constructor to avoid this - at the cost of the corresponding additional resources.
I agree that the newly introduced UserIdentity is a better approach for passing current user data to the report. It may be considered as further improvement along with the performance enhancement related to report rendering engine of all REST reports services using dedicated rendering thread queue (the feature that required UserIdentity to be introduced).
Regards,
Todor
Progress Telerik