How can a report access the Request.ServerVariables collection? What we are
trying to do is customize a piece of the report (through an if statement)
depending on one of the values in the ServerVariables collection, and if we
create a custom assembly, it doesn't have access to the Request object.Hi David,
In the Report properties window, under the Reference tab, you should add
a reference to the System.Web namespace, the HttpRequest class is located in
there, and you should be able to call it in a function (declared in the Code
tab).
I hope this helps,
Daniel.
"David" wrote:
> How can a report access the Request.ServerVariables collection? What we are
> trying to do is customize a piece of the report (through an if statement)
> depending on one of the values in the ServerVariables collection, and if we
> create a custom assembly, it doesn't have access to the Request object.|||Thanks for the info, Daniel. I am able to reference the HttpRequest class in
a function in the Code tab after adding a reference to the System.Web
namespace. However, I don't think it is properly accessing the current
Request object. When I try the code block below, it gives #Error.
Function GetServerName() As String
Return System.Web.HttpContext.Current.Request.ServerVariable("server_name")
End Function
And then in the report, say =Code.GetServerName()
Please let me know if you have luck with this, or can give more suggestions.
Thanks!
"daniel_xi" wrote:
> Hi David,
> In the Report properties window, under the Reference tab, you should add
> a reference to the System.Web namespace, the HttpRequest class is located in
> there, and you should be able to call it in a function (declared in the Code
> tab).
> I hope this helps,
> Daniel.
> "David" wrote:
> > How can a report access the Request.ServerVariables collection? What we are
> > trying to do is customize a piece of the report (through an if statement)
> > depending on one of the values in the ServerVariables collection, and if we
> > create a custom assembly, it doesn't have access to the Request object.|||Hi David,
It seems to be a permisison related issue. You may try to add the following
code to see if it helps
System.Security.PermissionSet ps = new System.Security.PermissionSet
(System.Security.Permissions.PermissionState.Unrestricted);
ps.Assert();
Also, please catch if there is any exception whening get context
Try
context = System.Web.HttpContext.Current
Catch ex As Exception
Return "Error getting context: " & ex.Message
End Try
Please refer to the following article for details:
How to grant permissions to a custom assembly that is referenced in a
report in Reporting Services
http://support.microsoft.com/?id=842419
Regards,
Peter Yang
MCSE2000/2003, MCSA, MCDBA
Microsoft Online Partner Support
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=====================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
>Thread-Topic: Can report access ServerVariables?
>thread-index: AcX1zJXxC9lyeoNdTYiBdeCxoHUxWQ==>X-WBNR-Posting-Host: 162.111.235.36
>From: "=?Utf-8?B?RGF2aWQ=?=" <dilworth@.newsgroups.nospam>
>References: <7D537990-C70F-4BBB-BE01-9AF32AE78CDB@.microsoft.com>
<4EDA9E61-C953-4A7E-9F18-EE0A8611E3E8@.microsoft.com>
>Subject: RE: Can report access ServerVariables?
>Date: Wed, 30 Nov 2005 08:39:08 -0800
>Lines: 33
>Message-ID: <6CEA2685-E588-4176-8F58-796AE68661EC@.microsoft.com>
>MIME-Version: 1.0
>Content-Type: text/plain;
> charset="Utf-8"
>Content-Transfer-Encoding: 7bit
>X-Newsreader: Microsoft CDO for Windows 2000
>Content-Class: urn:content-classes:message
>Importance: normal
>Priority: normal
>X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
>Newsgroups: microsoft.public.sqlserver.reportingsvcs
>NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
>Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
>Xref: TK2MSFTNGXA02.phx.gbl microsoft.public.sqlserver.reportingsvcs:64184
>X-Tomcat-NG: microsoft.public.sqlserver.reportingsvcs
>Thanks for the info, Daniel. I am able to reference the HttpRequest class
in
>a function in the Code tab after adding a reference to the System.Web
>namespace. However, I don't think it is properly accessing the current
>Request object. When I try the code block below, it gives #Error.
>Function GetServerName() As String
> Return
System.Web.HttpContext.Current.Request.ServerVariable("server_name")
>End Function
>And then in the report, say =Code.GetServerName()
>Please let me know if you have luck with this, or can give more
suggestions.
> Thanks!
>"daniel_xi" wrote:
>> Hi David,
>> In the Report properties window, under the Reference tab, you should
add
>> a reference to the System.Web namespace, the HttpRequest class is
located in
>> there, and you should be able to call it in a function (declared in the
Code
>> tab).
>> I hope this helps,
>> Daniel.
>> "David" wrote:
>> > How can a report access the Request.ServerVariables collection? What
we are
>> > trying to do is customize a piece of the report (through an if
statement)
>> > depending on one of the values in the ServerVariables collection, and
if we
>> > create a custom assembly, it doesn't have access to the Request object.
>|||Hi Peter,
I don't understand: David was referring to the System.Web.dll file, which
is already placed in the appropriate folders; this is not a custom DLL, it
comes with the .NET framework, is there still a permissions issue with this
system DLL?
I added a reference to it in the Report properties' Reference tab area,
but still could not make it work, using David's example listed below, by
calling the class property from a function in the Code tab.
Daniel.
"Peter Yang [MSFT]" wrote:
> Hi David,
> It seems to be a permisison related issue. You may try to add the following
> code to see if it helps
> System.Security.PermissionSet ps = new System.Security.PermissionSet
> (System.Security.Permissions.PermissionState.Unrestricted);
> ps.Assert();
> Also, please catch if there is any exception whening get context
> Try
> context = System.Web.HttpContext.Current
> Catch ex As Exception
> Return "Error getting context: " & ex.Message
> End Try
> Please refer to the following article for details:
> How to grant permissions to a custom assembly that is referenced in a
> report in Reporting Services
> http://support.microsoft.com/?id=842419
> Regards,
> Peter Yang
> MCSE2000/2003, MCSA, MCDBA
> Microsoft Online Partner Support
> When responding to posts, please "Reply to Group" via your newsreader so
> that others may learn and benefit from your issue.
> =====================================================>
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
> --
> >Thread-Topic: Can report access ServerVariables?
> >thread-index: AcX1zJXxC9lyeoNdTYiBdeCxoHUxWQ==> >X-WBNR-Posting-Host: 162.111.235.36
> >From: "=?Utf-8?B?RGF2aWQ=?=" <dilworth@.newsgroups.nospam>
> >References: <7D537990-C70F-4BBB-BE01-9AF32AE78CDB@.microsoft.com>
> <4EDA9E61-C953-4A7E-9F18-EE0A8611E3E8@.microsoft.com>
> >Subject: RE: Can report access ServerVariables?
> >Date: Wed, 30 Nov 2005 08:39:08 -0800
> >Lines: 33
> >Message-ID: <6CEA2685-E588-4176-8F58-796AE68661EC@.microsoft.com>
> >MIME-Version: 1.0
> >Content-Type: text/plain;
> > charset="Utf-8"
> >Content-Transfer-Encoding: 7bit
> >X-Newsreader: Microsoft CDO for Windows 2000
> >Content-Class: urn:content-classes:message
> >Importance: normal
> >Priority: normal
> >X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
> >Newsgroups: microsoft.public.sqlserver.reportingsvcs
> >NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
> >Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
> >Xref: TK2MSFTNGXA02.phx.gbl microsoft.public.sqlserver.reportingsvcs:64184
> >X-Tomcat-NG: microsoft.public.sqlserver.reportingsvcs
> >
> >Thanks for the info, Daniel. I am able to reference the HttpRequest class
> in
> >a function in the Code tab after adding a reference to the System.Web
> >namespace. However, I don't think it is properly accessing the current
> >Request object. When I try the code block below, it gives #Error.
> >
> >Function GetServerName() As String
> > Return
> System.Web.HttpContext.Current.Request.ServerVariable("server_name")
> >End Function
> >
> >And then in the report, say =Code.GetServerName()
> >
> >Please let me know if you have luck with this, or can give more
> suggestions.
> > Thanks!
> >
> >"daniel_xi" wrote:
> >
> >> Hi David,
> >>
> >> In the Report properties window, under the Reference tab, you should
> add
> >> a reference to the System.Web namespace, the HttpRequest class is
> located in
> >> there, and you should be able to call it in a function (declared in the
> Code
> >> tab).
> >>
> >> I hope this helps,
> >>
> >> Daniel.
> >>
> >> "David" wrote:
> >>
> >> > How can a report access the Request.ServerVariables collection? What
> we are
> >> > trying to do is customize a piece of the report (through an if
> statement)
> >> > depending on one of the values in the ServerVariables collection, and
> if we
> >> > create a custom assembly, it doesn't have access to the Request object.
> >
>|||Hello Daniel,
Based on my test, it seems we cannot get proper current context inside
assmbly code. I used the following code in the custom assembly but I
received "context is nothing" in the test report.
Public Shared Function GetServerName() As String
Dim ps As System.Security.PermissionSet
Dim context As System.Web.HttpContext
ps = New
System.Security.PermissionSet(System.Security.Permissions.PermissionState.Un
restricted)
ps.Assert()
Try
context = System.Web.HttpContext.Current
Catch ex As Exception
Return "error getting context" & ex.Message
End Try
'Return context.Request.ServerVariables("server_name")
If context Is Nothing Then
Return "context is nothing"
End If
Return "context is ok"
End Function
Best Regards,
Peter Yang
MCSE2000/2003, MCSA, MCDBA
Microsoft Online Partner Support
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=====================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
>Thread-Topic: Can report access ServerVariables?
>thread-index: AcX3S1g4qkdWUx/PTQi9qrssfMbMGA==>X-WBNR-Posting-Host: 68.236.108.222
>From: =?Utf-8?B?ZGFuaWVsX3hp?= <danielxi@.discussions.microsoft.com>
>References: <7D537990-C70F-4BBB-BE01-9AF32AE78CDB@.microsoft.com>
<4EDA9E61-C953-4A7E-9F18-EE0A8611E3E8@.microsoft.com>
<6CEA2685-E588-4176-8F58-796AE68661EC@.microsoft.com>
<tCWA8oy9FHA.4000@.TK2MSFTNGXA02.phx.gbl>
>Subject: RE: Can report access ServerVariables?
>Date: Fri, 2 Dec 2005 06:19:02 -0800
>Lines: 125
>Message-ID: <51926A21-18BC-4DBE-B495-B57C2D2E87A2@.microsoft.com>
>MIME-Version: 1.0
>Content-Type: text/plain;
> charset="Utf-8"
>Content-Transfer-Encoding: 7bit
>X-Newsreader: Microsoft CDO for Windows 2000
>Content-Class: urn:content-classes:message
>Importance: normal
>Priority: normal
>X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
>Newsgroups: microsoft.public.sqlserver.reportingsvcs
>NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
>Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGXA03.phx.gbl
>Xref: TK2MSFTNGXA02.phx.gbl microsoft.public.sqlserver.reportingsvcs:64320
>X-Tomcat-NG: microsoft.public.sqlserver.reportingsvcs
>Hi Peter,
> I don't understand: David was referring to the System.Web.dll file,
which
>is already placed in the appropriate folders; this is not a custom DLL, it
>comes with the .NET framework, is there still a permissions issue with
this
>system DLL?
> I added a reference to it in the Report properties' Reference tab area,
>but still could not make it work, using David's example listed below, by
>calling the class property from a function in the Code tab.
> Daniel.
>
>"Peter Yang [MSFT]" wrote:
>> Hi David,
>> It seems to be a permisison related issue. You may try to add the
following
>> code to see if it helps
>> System.Security.PermissionSet ps = new System.Security.PermissionSet
>> (System.Security.Permissions.PermissionState.Unrestricted);
>> ps.Assert();
>> Also, please catch if there is any exception whening get context
>> Try
>> context = System.Web.HttpContext.Current
>> Catch ex As Exception
>> Return "Error getting context: " & ex.Message
>> End Try
>> Please refer to the following article for details:
>> How to grant permissions to a custom assembly that is referenced in a
>> report in Reporting Services
>> http://support.microsoft.com/?id=842419
>> Regards,
>> Peter Yang
>> MCSE2000/2003, MCSA, MCDBA
>> Microsoft Online Partner Support
>> When responding to posts, please "Reply to Group" via your newsreader so
>> that others may learn and benefit from your issue.
>> =====================================================>>
>> This posting is provided "AS IS" with no warranties, and confers no
rights.
>>
>> --
>> >Thread-Topic: Can report access ServerVariables?
>> >thread-index: AcX1zJXxC9lyeoNdTYiBdeCxoHUxWQ==>> >X-WBNR-Posting-Host: 162.111.235.36
>> >From: "=?Utf-8?B?RGF2aWQ=?=" <dilworth@.newsgroups.nospam>
>> >References: <7D537990-C70F-4BBB-BE01-9AF32AE78CDB@.microsoft.com>
>> <4EDA9E61-C953-4A7E-9F18-EE0A8611E3E8@.microsoft.com>
>> >Subject: RE: Can report access ServerVariables?
>> >Date: Wed, 30 Nov 2005 08:39:08 -0800
>> >Lines: 33
>> >Message-ID: <6CEA2685-E588-4176-8F58-796AE68661EC@.microsoft.com>
>> >MIME-Version: 1.0
>> >Content-Type: text/plain;
>> > charset="Utf-8"
>> >Content-Transfer-Encoding: 7bit
>> >X-Newsreader: Microsoft CDO for Windows 2000
>> >Content-Class: urn:content-classes:message
>> >Importance: normal
>> >Priority: normal
>> >X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
>> >Newsgroups: microsoft.public.sqlserver.reportingsvcs
>> >NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
>> >Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
>> >Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.sqlserver.reportingsvcs:64184
>> >X-Tomcat-NG: microsoft.public.sqlserver.reportingsvcs
>> >
>> >Thanks for the info, Daniel. I am able to reference the HttpRequest
class
>> in
>> >a function in the Code tab after adding a reference to the System.Web
>> >namespace. However, I don't think it is properly accessing the current
>> >Request object. When I try the code block below, it gives #Error.
>> >
>> >Function GetServerName() As String
>> > Return
>> System.Web.HttpContext.Current.Request.ServerVariable("server_name")
>> >End Function
>> >
>> >And then in the report, say =Code.GetServerName()
>> >
>> >Please let me know if you have luck with this, or can give more
>> suggestions.
>> > Thanks!
>> >
>> >"daniel_xi" wrote:
>> >
>> >> Hi David,
>> >>
>> >> In the Report properties window, under the Reference tab, you
should
>> add
>> >> a reference to the System.Web namespace, the HttpRequest class is
>> located in
>> >> there, and you should be able to call it in a function (declared in
the
>> Code
>> >> tab).
>> >>
>> >> I hope this helps,
>> >>
>> >> Daniel.
>> >>
>> >> "David" wrote:
>> >>
>> >> > How can a report access the Request.ServerVariables collection?
What
>> we are
>> >> > trying to do is customize a piece of the report (through an if
>> statement)
>> >> > depending on one of the values in the ServerVariables collection,
and
>> if we
>> >> > create a custom assembly, it doesn't have access to the Request
object.
>> >
>>
>
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment