Getting a HttpContext error in the data-retrieval method executed by an ObjectDataSource component
Environment
Product | Progress® Telerik® Reporting |
Project Type | Web Application |
Report Item | ObjectDataSource Component |
Error Message
HttpContext.Current.User is not available.
Cause
The data-retrieval method is executed in a different context where the current user's information is not transferred.
Description
HttpContext.Current.User is not available in the data-retrieval method executed by an ObjectDataSource component. This is a result of the data-retrieval method being executed in a different context where the current user's information is not available.
Solution
You can parameterize the data-retrieval method and pass the ID of the user (as Integer, String) via report parameter e.g. Using Parameters with the ObjectDataSource Component. In the data-retrieval method you can use the passed ID or re-retrieve the users' information.
Notes
If you are using the HTML5 Viewer and Reporting REST WebAPI based service, to secure the information transferred in requests, please consider encrypting it and using HTTPS. The current context and user will be available in the Reporting REST service's methods. If you need to check and compare the client(viewer)'s information on the server, you can override the ReportsControllerBase methods like GetParameters and CreateInstance.
See Also
How To Enable HTTPS In ASP.NET Web API
How to use information from HttpContext in Custom Report Resolver