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
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:
Or maybe in some particular port ... for example
http:
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