HttpContext Error in ObjectDataSource Data-retrieval Method
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
or 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
.