Forgot password?

FastReport .Net 2013.2 MVC

Alexander Fediachov

We have released FastReport .Net 2013.2 with MVC support. And I'd like to inform all WebReport developers about some changes.

First. An extension of the handler in web.config was changed. You need replace old string «FastReport.Export.aspx» to new string «FastReport.Export.axd» everywere. Web application without these changes will throw an exception and you will see text with error and instructions for changes in web.report.

You can check the handler of WebReport by typing in the address bar: http://site_address/app_folder/ FastReport.Export.axd (replace site_address and app_folder with your values).

In the successfull request case you'll see FastReport version number and server time.

Second. We have added support of ASP.NET MVC framework. You will not have any troubles with using our control in ASPX (MVC 2) – You'll just enough drag control from Toolbox to the page. WebReport will set all needed changes in web.config automatically. Let see the demo of WebReport in aspx in folder \Demos\C#\MvcDemo.

Also I should say how to use the WebReport in Razor (MVC 3,4).  You will need add lines with handler defenitions in web.config in root folder of your web-application.  Add line in section <system.webServer> <handlers> for using in IIS7:
<add name="FastReportHandler" path="FastReport.Export.axd" verb="*" type="FastReport.Web.Handlers.WebExport" />

Add line in section <system.web> <httpHandlers> for using in IIS6:
<add path="FastReport.Export.axd" verb="*" type="FastReport.Web.Handlers.WebExport" />

Then you should modify web.config in folder with Views.  Add lines in section <system.web.webPages.razor> <namespaces>:
<add namespace="FastReport" />
<add namespace="FastReport.Web" />

Add lines in file _Layout.cshtml in tag <head>:
@WebReportGlobals.Scripts()
@WebReportGlobals.Styles()

Now you can draw the report on the View. Go to the controller and create a WebReport:
WebReport webReport = new WebReport(); // create object
webReport.Width = 600;  // set width
webReport.Height = 800; // set height
webReport.Report.RegisterData(dataSet, "AppData"); // data binding
webReport.ReportFile = this.Server.MapPath("~/App_Data/report.frx");  // load the report from the file
ViewBag.WebReport = webReport; // send object to the View

Go to View and add the line:
@ViewBag.WebReport.GetHtml()

Similar code to create WebReport you can also write directly in View.

Let see the demo of WebReport in Razor in folder \Demos\C#\MvcRazor. There are various samples for load the report, including preprepared, and there is an example of using event StartReport.

Do not forget to add the missing dll in bin directory.

Similar articles:

back