Couldn't able to use System.Web.HttpContext.Current.Req uest.Url.AbsoluteUri in Custom code
Hi,
I'm trying to get the absolute url of the current report(need to get HistoryID) http://<Server>/Reports/Pages/Report.aspx?ItemPath=%2fSnapShot+POC%2fTest1_SubReport&HistoryID=2011-01-10T14:32:34.
I have added System.Web.dll as reference in Report properties.
Method :
public Function Test() as string
strurl = System.Web.HttpContext.Current.Request.Url.AbsoluteUri
return strurl End Function
In textbox expression "=Code.Test()"
Deployed in Report Manager & it throws "#Error".
Also given FullTrust for "AspNetHostingPermission" (for System.Web.dll) in rssrvpolicy.Config,RSPreviewPolicy.Config & rsmgrpolicy.Config File
Thanks...
January 20th, 2011 1:01am
Hi Dev team,
As you may know, the issue is caused by the Code Acess Security setting.
The temporary workaround is set the following code group in the rsmgrpolicy.config and rssrvpolicy.config as FullTrust:
<CodeGroup
class="FirstMatchCodeGroup"
version="1"
PermissionSetName="FullTrust"
Description="This code group grants MyComputer code Execution permission. ">
<IMembershipCondition
class="ZoneMembershipCondition"
version="1"
Zone="MyComputer" />
This workaround will cause all code in reports in the report server to be FullTrust.
The best solution is embedded the code in a custom assembly, and then set the assembly to be FullTrust. You should add the following code to the method to enable the code:
System.Web.
AspNetHostingPermission
p = new
System.Web.AspNetHostingPermission(System.Security.Permissions.PermissionState.Unrestricted);
p.Assert();
For more information, please see:
How to grant permissions to a custom assembly that is referenced in a report in Reporting Services:
http://support.microsoft.com/kb/842419
If you have any more questions, please feel free to ask.
Thanks,
Jin ChenJin Chen - MSFT
Free Windows Admin Tool Kit Click here and download it now
January 21st, 2011 2:34am
Also, the code we used will get the absolute url of the report. The URL you posted is the URL of the report manager.
You should try using the method described in the following thread to get the URL:
http://social.msdn.microsoft.com/Forums/en/sqlreportingservices/thread/11fabef3-8eec-4fbb-be13-7ba068692e50
Thanks,
Jin ChenJin Chen - MSFT
January 21st, 2011 2:37am
Thanks Jin Chen...Its working fine...
As u suggested i created a custom assembly & given FullTrust. This is my method,
public
static
string getCurrentHistId()
{
string val =
"";
AspNetHostingPermission webPer =
new System.Web.AspNetHostingPermission(System.Security.Permissions.PermissionState.Unrestricted);
webPer.Assert();
val =
HttpContext.Current.Request.Url.AbsoluteUri;
return
val
;
}
Free Windows Admin Tool Kit Click here and download it now
January 24th, 2011 11:49pm