My project developed in MVC3 Razor Tech. My master page and content page are developed with Razor MVC3. I want to show a SSRS report builder on my project. I searched in blogs and come to know that we can't show the SSRS reports in MVC3 Razor.
Since We can used 'webform'
in MVC3 we can show the report.
Problems: In my project both master and content page are all developed with Razor .cshtml
Since accessing .aspx
is difficult.Correct me if I'm wrong.
Requirement: Please help me to show the webforms in the 'VIEW'
MVC3 Razor framwork.i.e My project landing page is the webform
. In that webform page I need to show the SSRS report
Answers. You don't need to add a special route to add a webforms . aspx page to your MVC applications. Just add the file and it will work as long as you don't put it in the Views folder.
Right click the Index. cshtml file and select View in Browser. You can also right click the Index. cshtml file and select View in Page Inspector.
The question of how to combine both technologies in one application arises—is it possible to combine both ASP.NET Webforms and ASP.NET MVC in one web application? Luckily, the answer is yes. Combining ASP.NET Webforms and ASP.NET MVC in one application is possible—in fact, it is quite easy.
One major advantage to aspx compared to cshtml is that you can view and edit the page itself (WUSIWYG kind of) using the design tab. With cshtml files you might as well use notepad to edit your html page. You are working "in the dark". @nivs1978: I actually find this to be a down-side of it.
I had to do it and so I worked for me :
Suppose you have a controller called Summary . For this implementation, You don't need to add or modify any of the actions that you have.
Then, as you told me, you add a file named "SkillReport.aspx" in your views folder
Views/Summary/SkillReport.aspx
( initially left in blank SkillReport.aspx or just add some text like "Skill report" )
In Global.asax :
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapPageRoute("Report", "Report/{rptController}/{rptName}", "~/Views/{rptController}/{rptName}.aspx");
...
}
****--> I have attached the snapshot of my solution explorer My routes.Mappageroute code is "routes.MapPageRoute("Report", "Report/Summary", "~/Views/Summary/SkillReport.aspx");" Please change the mapPageRoute for the above folder structure.** <--
The values enclosed in {} are placeholders. You must not give the name of the controller or report there. When a request is received, this route determines which controller to invoke by adding the suffix "rptController" to the controller value in the URL to determine the type name of the controller that will handle the request. The rptName value in the URL determines which WebForm.aspx to call.
Suppose you need other two reports.
Using the parameters you avoid having to create a route for each report.
routes.MapPageRoute("Report", "Report/{rptController}/{rptName}", "~/Views/{rptController}/{rptName}.aspx");
http://localhost/Report/Summary/SkillReport --> /Views/Summary/SkillReport.aspx
http://localhost/Report/Summary/FullNames --> /Views/Summary/FullNames.aspx
http://localhost/Report/Product/List --> /Views/Product/List.aspx
On this route we added:
"Report" is the name of this route, you can put any other
"Report/{rptController}/{rptName}" : This is the pattern URL to identify when to invoke your Report-WebForm, "Report" works as "key" and {rptController} is the name of the controller. rptController will be assigned with the Controller name. In this case Summary and rptName with SkillReport
"~/Views/{rptController}/{rptName}.aspx" is the physical path. When using this route with Summary controller, and call SkillReport this will invoke to Views/Summary/SkillReport.aspx
Routing documentation: http://msdn.microsoft.com/en-us/library/cc668201(v=vs.100).aspx#url_patterns
At this point you can verify that you can access your SkillReport.aspx in your development environment using :
http://localhost/Report/Summary/SkillReport
Or maybe at some particular port... like
http://localhost:1057/Report/Summary/SkillReport
Finally, SkillReport.aspx (like this... check ProcessingMode...)
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SkillReport.aspx.cs" Inherits="XXX.SkillReport" %>
<%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" >
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<meta http-equiv="X-UA-Compatible" content="IE=100"/>
</head>
<body>
<form id="frmRpt" runat="server">
<div>
<asp:ScriptManager ID="sm" runat="server">
</asp:ScriptManager>
<rsweb:ReportViewer ID="rpt" runat="server" Width="100%" Height="90%" AsyncRendering="false" ProcessingMode="Local" ShowRefreshButton="false">
</rsweb:ReportViewer>
</div>
</form>
</body>
</html>
With this tag
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" >
you achieve that show in Safari and other browsers.
To access the report from a VIEW (.cshtml) need to add a link. i. e. :
<a href="/Report/Summary/SkillReport" >Show My Report :) </a>
As a last comment, I recommend that after creating SkillReport.aspx enter in "Design Mode" and drag from the toolbox the Reporting's controls. This will automatically register the required values in web.config
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With