Display SSRS Reports in Blazor Server App (For Free)

Viewed 1852
1 Answers

Have you tried docking it in an iFrame with the source set to the web link to the report?

I got this to work:

<iframe src="https://<SQLSERVER>.<domain>.com/Reports/report/<Report>?rs:Embed=true&rc:Toolbar=false"></iframe>

NOTE: using http:// in the source will definitely NOT work.

iframes allow you to set the source for their content to a URL. With SSRS having a URL for their reports, that gives you a way to link the report to the iframe in question. Additionally, SSRS reports allow for commands and parameters to also be used in that URL. IE: The rs:Embed=true and the Toolbar=false options you see in the URL I provided.

Make sure you copy and paste the URL you're trying to set as the source into a browser first though to make sure it'll work. If it doesn't load in it's own window/tab... it won't work in the code either.

If you want to pass a parameter to the source, an easy way is to do this:

For the iframe (Note the src="@(URL)"):

<iframe id="PreviewClaim" style="float: left; right: 5px; top: 65px; height: 865px; width: 1659px;" src="@(URL)"></iframe>

The button click used to generate it (Mine pops up in a modal):

<button class="btn btn-primary" @onclick="@(() => preview(claim.ClaimID))">Preview</button>

And the C#:

bool showModal = false;
string URL = string.Empty;
void preview(int ClaimID)
{
    showModal = true;
    URL = "https://<SQLSERVER>.<DOMAIN>.com/Reports/report/ClaimPreview?rs:Embed=true&rc:Toolbar=false&ClaimID=" + ClaimID.ToString();        
}
Related