How to show .aspx web form page in VIEW MVC3 Razor

My project was developed in MVC3 Razor Tech. My homepage and content page are developed using Razor MVC3. I want to show SSRS Report Builder in my project. I searched the blogs and found out that we cannot display SSRS reports in MVC3 Razor. Since we can use 'webform' in MVC3, we can show a report.

Problems: In my project, both the main page and the content page were developed using Razor .cshtml because access to .aspx difficult. Change me if I'm wrong.

Demand. Please help me show web forms in 'VIEW' MVC3 Razor framwork.ie My project target page is webform . On this web form page I need to show SSRS report

+6
source share
3 answers

I had to do this, so I worked for me:

Suppose you have a controller named Summary . For this implementation, you do not need to add or modify any actions that you have.

Then, as you said, you add a file called "SkillReport.aspx" to your view folder

  Views/Summary/SkillReport.aspx 

(initially left in empty SkillReport.aspx or just add some text, for example, "Skill Report")

At Global.asax:

  public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapPageRoute("Report", "Report/{rptController}/{rptName}", "~/Views/{rptController}/{rptName}.aspx"); ... } 

**** β†’ I attached a snapshot of my solution browser enter image description here My routes. "routes.MapPageRoute (" Report "," Report / Summary "," ~ / Views / Summary / SkillReport.aspx "); Change mapPageRoute for the above folder structure. ** <-

Values ​​enclosed in {} are placeholders . You must not provide a controller name or report it. When a request is received, this route determines which controller to call by adding the suffix "rptController" to the value of the controller in the URL to determine the name of the type of controller that will process the request. The rptName value in the URL determines which WebForm.aspx to call.

Suppose you need two other reports.

  • The Pivot Controller and the FullNames Report Name
  • In the controller named Product and the list of report names.

Using parameters, you avoid creating 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 URL of the template to identify when, to invoke your Report-WebForm, the "Report" acts as a "key" and {rptController} is the name of the controller. rptController will be assigned the name of the controller. In this case, the Summary and rptName with SkillReport

  • "~ / Views / {rptController} /{rptNameasure.aspx" is the physical track. When using this route with the Summary controller and calling SkillReport it will be 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 in some particular port ... for example

 http://localhost:1057/Report/Summary/SkillReport 

Finally, SkillReport.aspx (e.g. 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 reach this show in Safari and other browsers.

To access the report from VIEW (.cshtml), you must add a link. I. e.

 <a href="/Report/Summary/SkillReport" >Show My Report :) </a> 

As a final comment, I recommend that after creating SkillReport.aspx enter β€œ Design Mode ” and drag and drop Reporting controls from the toolbar . This will automatically register the required values ​​in web.config

+9
source

Answer # 1 was helpful:

Just make sure your MapRoutes order is in the correct priority order:

eg:.

  public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapPageRoute( routeName: "Report/", routeUrl: "Report/{rptController}/{rptName}", physicalFile: "~/Views/{rptController}/{rptName}.aspx" ); routes.MapRoute( name: "Default", url: "{controller}/{action}/{id}", defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } ); } 
+2
source

Although this will not be the recommended practice, it is doable. I am copying a link that shows you how to use two view engines in one project.

http://weblogs.asp.net/gunnarpeipman/archive/2010/07/29/asp-net-mvc-3-using-multiple-view-engines-in-same-project.aspx

Let me know if this works for you.

Update: It may also help, another option looks like registering a route for your aspx page.

[StackOverflow Post] Aspx page in MVC3

+1
source

All Articles