Recently I got a task of Displaying SSRS report in ASP.NET MVC application.
Initially I thought this might not be possible in MVC
application(Since web forms have ReportViewer control which is server side control
requiring view state and which is not possible in MVC) and I would have to do
some work around of mixing MVC and ASP.NET Web Forms pages to view report.
Later on I searched some more and found this solution. So
let us start with it.
I created a
BI solution and created a simple report(named EmpReport) as shown below.
I deployed
this solution to my local SSRS server. Now my requirement is to display this
deployed report in my MVC application.
I Created a MVC project(named Mvc_SSRS_Demo) where I would like to integrate this report.
We would install "MvcReportViewer" package from
NuGet.
To install it open 'Package Manager Console' from Visual Studio Tools --> Library Package
Manager --> Package Manager Console
and Run following command in 'Package Manager Console'
Install-Package MvcReportViewer
This will add packages for MvcReportViewer library and will
add some default configurations in web.config
We will have to update following entries in web.config
<add key="MvcReportViewer.AspxViewer" value="/MvcReportViewer.aspx" />
=> This points to aspx page which
is installed by NuGet package which will be used to display our report in
iframe. If you move this page to some other location or rename it then you will
have to update that change here.
<add key="MvcReportViewer.ReportServerUrl" value="http://naren-pc/Reportserver" />
=> This points to
SSRS server where our report is deployed. Change this value to point it to your
report server.
<add key="MvcReportViewer.Username" value="" />
<add key="MvcReportViewer.Password"
value="" />
=> Provide
credentials if required to connect to your report server.
Now to use
this Report Viewer in your view Reference it as follows
@using MvcReportViewer
Now use following
HTML helper method to load required report
@Html.MvcReportViewer(
"/MvcSSRS_Integration/EmpReport",
new { EmpID = 1 },
new { Height = 600,
Width = 600, style = "border:
none" })
This helper
method has following parameters
1. Relative
path of SSRS report on server
2. Required Parameters
for report execution
3. Styling
and other settings for report viewer
Now Run your application and navigate to this View and it
will render your SSRS report in your MVC application. Pretty cool :)
Hope this makes it clear and helps you.
Hi.
ReplyDeleteASP.NET 5 does not have web.config. Rather it has project.json file which is quite different from web.config. How this NuGet package will work with ASP.NET 5
This package works for .aspx page but ASP.NET 5 does not have .aspx page. Microsoft is going to remove web forms.
ReplyDeleteHi Naren:
ReplyDeleteI know this post is a few years old, but I'm hoping you can help me. I've followed your instructions, but @Html.MvcReportViewer isn't an option for me. I'm trying to use it in an ASP.Net w/Razor solution and am stuck. Any tips on trouble shooting would help. Thank you.
It's amazing blog, Thanks for sharing
ReplyDelete.Net Online Course
Hi Phil DeBlanc, You might not have successfully installed "MvcReportViewer" package from NuGet. Check again if it was installed successfully and you got required libraries added in project after installing this package.
ReplyDeleteAny good tutorial on github.com/ilich/MvcReportViewer please?
ReplyDeleteYour work is very good and I appreciate you and hopping for some more informative posts
ReplyDeleteDot Net Training in Chennai | Dot Net Training in anna nagar | Dot Net Training in omr | Dot Net Training in porur | Dot Net Training in tambaram | Dot Net Training in velachery
smm panel
ReplyDeleteSmm panel
iş ilanları
instagram takipçi satın al
HIRDAVAT
Https://www.beyazesyateknikservisi.com.tr/
Servis
Tiktok para hilesi indir
pendik bosch klima servisi
ReplyDeletekadıköy samsung klima servisi
maltepe mitsubishi klima servisi
üsküdar beko klima servisi
ataşehir alarko carrier klima servisi
çekmeköy daikin klima servisi
ümraniye mitsubishi klima servisi
beykoz vestel klima servisi
tuzla arçelik klima servisi