Viewer is not displayed in MVC View with custom Routes

Stimulsoft Reports.WEB discussion
Post Reply
marianux
Posts: 11
Joined: Thu Oct 24, 2013 5:15 pm

Viewer is not displayed in MVC View with custom Routes

Post by marianux »

Hi,
we have migrated our ASP.NET webform app to ASP.NET MVC 4 app in a theme with bootstrap style and custom routes for the most of views.
We have been working with Stimulsoft for showing reports in old web app and we want to keep on working with Stimulsoft.
We got, f.i., a view to display a invoice.
Route URL for that view is: localhost:XXXX/invoices/id/report where id is the number id of invoice.
That Route is linked to Controller: Invoices and Action: InvoiceReport (int id)

In controller i have added Actions GetReportSnapshot and ViewerEvent
In View InvoiceReport i have added following script:

Code: Select all

@Html.Stimulsoft().StiMvcViewer(new StiMvcViewerOptions()
                {
                    Actions =
                    {
                        GetReportSnapshot = "GetReportSnapshot",
                        ViewerEvent = "ViewerEvent",
                        }
                })
But it never shows any report. In Debug Mode it never goes to Action GetReportSnapshot.
And in HTML code resultant i see this:

Code: Select all

<div id="MvcViewer" style="background-color:White;height:100%;width:100%;"><script type="text/javascript" src="http://localhost:13530/invoices/14/report?mvcviewer_resource=scripts&mvcviewer_id=MvcViewer&mvcviewer_theme=Office2013&mvcviewer_version=2016.2"></script>
If i go to js file referenced i get HTML for same view.
But when i execute f.i. Samples-ASP.NET-MVC-CSharp/Change the Viewer Theme/ in html code i get this code:

Code: Select all

<div id="MvcViewer" style="background-color:White;height:100%;width:100%;"><script type="text/javascript" src="http://localhost:53101/Viewer/ViewerEvent?mvcviewer_resource=scripts&mvcviewer_id=MvcViewer&mvcviewer_theme=Office2013&mvcviewer_version=2016.3"></script>
and if i go to this js file i get js code for settings option for report.

In my view reference to js view doesnt contains the Action name for ViewerEvent.
So i think problem could be something about routing.
Any idea to fix it.?
thanks in advance.
Last edited by marianux on Fri Dec 09, 2016 12:02 pm, edited 3 times in total.
marianux
Posts: 11
Joined: Thu Oct 24, 2013 5:15 pm

Re: Viewer is not displayed in MVC View

Post by marianux »

UPDATE

In have modified RouteConfig.cs in your sample : Show Report in the Viewer

- I have added next code before routename: "Default",

Code: Select all

routes.MapRoute(
                name: "Reports",
                url: "reports",
                defaults: new { controller = "Viewer", action = "Index" }
            );
Then i run app and then it goes to http://localhost:53101/reports but doesnt display Report.
In html code:

Code: Select all

<div id="MvcViewer" style="background-color:White;height:100%;width:100%;"><script type="text/javascript" src="http://localhost:53101/reports?mvcviewer_resource=scripts&mvcviewer_id=MvcViewer&mvcviewer_theme=Office2013&mvcviewer_version=2016.3"></script><div id="MvcViewer_MvcViewerMainPanel" class="stiMvcViewerMainPanel"><script type="text/javascript">var jsMvcViewer = new StiMvcViewer({options:{"requestStylesUrl":"http://localhost:53101/reports","exports":{"showExportDialog":true,"showExportToDocument":true,"showExportToPdf":true,"showExportToXps":true,"showExportToPowerPoint":true,"showExportToHtml":true,"showExportToHtml5":true,"showExportToMht":true,"showExportToText":true,"showExportToRtf":true,"showExportToWord2007":true,"showExportToOpenDocumentWriter":true,"showExportToExcel":true,"showExportToExcelXml":true,"showExportToExcel2007":true,"showExportToOpenDocumentCalc":true,"showExportToCsv":true,"showExportToDbf":true,"showExportToXml":true,"showExportToDif":true,"showExportToSylk":true,"showExportToImageBmp":true,"showExportToImageGif":true,"showExportToImageJpeg":true,"showExportToImagePcx":true,"showExportToImagePng":true,"showExportToImageTiff":true,"showExportToImageMetafile":true,"showExportToImageSvg":true,"showExportToImageSvgz":true},"appearance":{"backgroundColor":"White","pageBorderColor":"Gray","rightToLeft":false,"fullScreenMode":false,"scrollbarsMode":false,"openLinksTarget":"_blank","openExportedReportTarget":"_blank","showTooltips":true,"showTooltipsHelp":true,"pageAlignment":"Center","showPageShadow":true,"bookmarksPrint":false,"bookmarksTreeWidth":180,"parametersPanelMaxHeight":300,"parametersPanelColumnsCount":2,"parametersPanelDateFormat":"","interfaceType":"Auto","chartRenderType":"AnimatedVector"},"actions":{"getReportSnapshot":"GetReportSnapshot","printReport":"","exportReport":"","emailReport":"","designReport":"","viewerEvent":"ViewerEvent","interaction":""},"routes":{"action":"Index","controller":"Viewer"},"shortProductVersion":"2016.3","toolbar":{"visible":true,"backgroundColor":"","borderColor":"","fontColor":"","fontFamily":"Arial","alignment":"Default","showButtonCaptions":true,"showPrintButton":true,"showSaveButton":true,"showSendEmailButton":false,"showFindButton":true,"showBookmarksButton":true,"showParametersButton":true,"showEditorButton":true,"showFullScreenButton":true,"showFirstPageButton":true,"showPreviousPageButton":true,"showCurrentPageControl":true,"showNextPageButton":true,"showLastPageButton":true,"showZoomButton":true,"showViewModeButton":true,"showDesignButton":false,"showAboutButton":true,"printDestination":"Default","viewMode":"OnePage","zoom":100,"menuAnimation":true,"showMenuMode":"Click"},"requestUrl":"http://localhost:53101/reports","server":{"controller":"Viewer","requestTimeout":20,"cacheTimeout":20,"cacheMode":"ObjectCache","globalReportCache":false,"cacheItemPriority":"Default","useRelativeUrls":false,"passQueryParametersForResources":true,"passFormValues":false},"formValues":{},"productVersion":"2016.3","email":{"showEmailDialog":true,"showExportDialog":true,"defaultEmailAddress":"","defaultEmailSubject":"","defaultEmailMessage":""},"cultureName":null,"viewerHeightType":"Percentage","viewerId":"MvcViewer","theme":"Office2013","requestAbsoluteUrl":"http://localhost:53101/reports"},defaultExportSettings:{"StiOdsExportSettings":{"ImageQuality":0.75,"ImageResolution":100.0,"PageRange":"All"},"StiXpsExportSettings":{"ImageQuality":0.75,"ExportRtfTextAsImage":false,"ImageResolution":100.0,"PageRange":"All"},"StiTxtExportSettings":{"ZoomX":1.0,"CutLongLines":true,"ZoomY":1.0,"EscapeCodesCollectionName":null,"Encoding":"65001","KillSpaceLines":true,"PageRange":"All","KillSpaceGraphLines":true,"UseEscapeCodes":false,"BorderType":"UnicodeSingle","DrawBorder":true,"PutFeedPageCode":true},"StiPdfExportSettings":{"SubjectNameString":"","ImageResolutionMode":"Exactly","DitheringType":"FloydSteinberg","UseLocalMachineCertificates":false,"ImageQuality":0.75,"ExportRtfTextAsImage":false,"DigitalSignatureSignedBy":null,"KeyLength":"Bit40","UseUnicode":true,"PdfACompliance":false,"PasswordInputOwner":"","AutoPrintMode":"None","ImageResolution":100.0,"StandardPdfFonts":false,"AllowEditable":"No","DigitalSignatureLocation":null,"GetCertificateFromCryptoUI":true,"CreatorString":"","Compressed":true,"KeywordsString":"","CertificateData":null,"UserAccessPrivileges":"All","DigitalSignatureReason":null,"ImageFormat":"Color","ImageCompressionMethod":"Jpeg","PageRange":"All","EmbeddedFiles":[],"PasswordInputUser":"","ZUGFeRDCompliance":false,"EmbeddedFonts":true,"DigitalSignatureContactInfo":null,"CertificatePassword":null,"PdfComplianceMode":"None","UseDigitalSignature":false},"StiRtfExportSettings":{"PageRange":"All","RemoveEmptySpaceAtBottom":true,"ExportMode":"Table","ImageResolution":100.0,"ImageQuality":0.75,"CodePage":0,"StoreImagesAsPng":false,"UsePageHeadersAndFooters":false},"StiWord2007ExportSettings":{"PageRange":"All","RemoveEmptySpaceAtBottom":true,"ImageResolution":100.0,"RestrictEditing":"No","ImageQuality":0.75,"UsePageHeadersAndFooters":false},"StiImageExportSettings":{"ImageZoom":1.0,"ImageType":"Jpeg","TiffCompressionScheme":"Default","CutEdges":false,"ImageResolution":100,"ImageFormat":"Color","DitheringType":"FloydSteinberg","MultipleFiles":false,"PageRange":"All"},"StiHtmlExportSettings":{"RemoveEmptySpaceAtBottom":true,"AddPageBreaks":true,"ImageResolution":96.0,"ContinuousPages":true,"OpenLinksTarget":null,"UseWatermarkMargins":false,"PageHorAlignment":"Left","PageRange":"All","HtmlType":"Html","ChartType":"AnimatedVector","Zoom":1.0,"ImageFormat":"Png","ExportQuality":"High","ExportBookmarksMode":"All","UseEmbeddedImages":false,"ImageQuality":0.75,"CompressToArchive":false,"BookmarksTreeWidth":150,"Encoding":"65001","UseStylesTable":true,"ExportMode":"Table"},"StiDataExportSettings":{"UseDefaultSystemEncoding":true,"Separator":";","PageRange":"All","Encoding":"65001","DataExportMode":"Data","CodePage":"Default","SkipColumnHeaders":false,"ExportDataOnly":false,"DataType":"Csv"},"StiPpt2007ExportSettings":{"ImageQuality":0.75,"ImageResolution":100.0,"PageRange":"All"},"StiOdtExportSettings":{"UsePageHeadersAndFooters":false,"ImageQuality":0.75,"PageRange":"All","ImageResolution":100.0,"RemoveEmptySpaceAtBottom":true},"StiExcelExportSettings":{"PageRange":"All","ExportPageBreaks":false,"ImageResolution":100.0,"UseOnePageHeaderAndFooter":false,"ExcelType":"ExcelBinary","ImageQuality":0.75,"ExportEachPageToSheet":false,"RestrictEditing":"No","ExportDataOnly":false,"ExportObjectFormatting":true}}})</script></div><script type="text/javascript">if (document.readyState == 'complete') jsMvcViewer.postAction(); else jsMvcViewer.addEvent(window, 'load', function () { jsMvcViewer.postAction() });</script></div>
        
As you see, url dont make reference to any action for reports.

I've made a test adding Server - controller to component:
@Html.Stimulsoft().StiMvcViewer(new StiMvcViewerOptions()
{
Actions =
{
GetReportSnapshot = "GetReportSnapshot",
ViewerEvent = "ViewerEvent"
},
Server =
{
Controller = "Viewer"
}
})
but it doesnt work

So it seems that there are problems with routing url.
Any idea?
Thanks in advance
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Viewer is not displayed in MVC View with custom Routes

Post by Alex K. »

Hello,

For the MVC viewer you should add {action} parameter in the route URL, otherwise, it will not be able to create correctly the URL to their queries on the server side.

Thank you.
marianux
Posts: 11
Joined: Thu Oct 24, 2013 5:15 pm

Re: Viewer is not displayed in MVC View with custom Routes

Post by marianux »

Aleksey wrote:Hello,

For the MVC viewer you should add {action} parameter in the route URL, otherwise, it will not be able to create correctly the URL to their queries on the server side.

Thank you.
Hi,
i dont understand how can i do that.
For my route for showing report of an invoice

Code: Select all

routes.MapRoute(
                                                  name: "reportsinvoice",
                                                  url: "invoices/{id}/reports",
                                                  defaults: new
                                                  {
                                                      controller = "Invoices",
                                                      action = "ReportsInvoice",
                                                  },
                                                  constraints: new { id = @"\d+"}
                                              )
ReportsInvoice is the default action for this route, its placed inside Invoices controller, when i go to this actions url would be eg invoices/268/reports it should show info from invoice and report viewer.
how can i add {action} parameter, could you modify my example from above for making test?
thanks in advance.
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Viewer is not displayed in MVC View with custom Routes

Post by HighAley »

Hello.

Sorry, maybe we missed something.
Please, send us a sample project that reproduces the issue.

Thank you.
ssh
Posts: 1
Joined: Fri May 12, 2017 5:00 am

Re: Viewer is not displayed in MVC View with custom Routes

Post by ssh »

have the same issue with 2017.1.

IE11: StiMvcViewer renders menu only, GetReport action is not called.
FF: no problem, renders full report

it seems to be a problem with IE compatibility view (default for intranet sites).
switching compatibility view off in IE (Tools->Compatibility View settings) or adding

Code: Select all

<meta http-equiv="x-ua-compatible" content="IE=Edge">
to the page head solves the problem.

regards,

ssh
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Viewer is not displayed in MVC View with custom Routes

Post by HighAley »

Hello, ssh.

We are testing our product and it is working right in IE11.
The StiMvcViewer is working in IE9+.
Unfortunately, in the Compatibility view the IE7 mode is enabled.
It's impossible to use our product in this mode.

Thank you.
Post Reply