Validating existence of image URL in report

Posted on 2009-02-10
Last Modified: 2012-05-06
I'm trying to validate the existence of an image URL for a report page in SQL Server Reporting Services.  The image URL is dynamically created based on an item number.  I either display the found image at the URL or a special image that indicates there are is no image for the item.  All of the images are on a virtual directory on the same server as the report server.

I've tried specifying the folder path \\servername\... and that does not work (as I would expect).  I also tried specifying custom code in the report using a programmatic web request (HttpWebRequest).  I expected that, but when I use it I get the following exception:

System.Security.SecurityException: Request for the permission of type 'System.Net.WebPermission, System, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet)
at System.Security.CodeAccessPermission.Demand()
at System.Net.HttpWebRequest..ctor(Uri uri, ServicePoint servicePoint)
at System.Net.HttpRequestCreator.Create(Uri Uri)
at System.Net.WebRequest.Create(Uri requestUri, Boolean useUriBase)
at System.Net.WebRequest.Create(String requestUriString)
at ReportExprHostImpl.CustomCodeProxy.UrlExists(String u)
The action that failed was:
The type of the first permission that failed was:
The Zone of the assembly that failed was:

This works in Visual Studio but does not work on the report server or another server on the network.  I need a method that works to perform this validation or work around it so that the special image is shown if the other image is missing.
Question by:Die-Tech
    1 Comment
    LVL 4

    Accepted Solution

    I was able to get my validation routine to work by adding the following line within the system.web tag in the report server web.config file:

    <trust level="Full" />

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    by Mark Wills Attending one of Rob Farley's seminars the other day, I heard the phrase "The Accidental DBA" and fell in love with it. It got me thinking about the plight of the newcomer to SQL Server...  So if you are the accidental DBA, or, simp…
    In SQL Server, when rows are selected from a table, does it retrieve data in the order in which it is inserted?  Many believe this is the case. Let us try to examine for ourselves with an example. To get started, use the following script, wh…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now