This is a migrated thread and some comments may be shown as answers.

Dynamic ExternalStyleSheet from Stream or URI

3 Answers 97 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
henry
Top achievements
Rank 1
henry asked on 24 Feb 2014, 03:09 PM
What Im trying to achieve is to load a dynamic externalstylesheet, where in the style rules can be configurable.

Unfortunately, I can not make this to work. Im getting the following error:

An error has occurred while processing Report 'MyReport':
For security reasons DTD is prohibited in this XML document. To enable DTD processing set the DtdProcessing

I also tried to use stream buy the errors says the buffer can not be null even though Im passing the right byte array.

Here are the codes:

public MyReport(Uri stylesheet): this()
{
   this.ExternalStyleSheets.Clear();
   this.ExternalStyleSheets.Add(new ExternalStyleSheet(stylesheet));
}

ReportController

public ActionResult MyReport()
{
   var xml = new Uri("http://mydomain.com" + Url.Action("ReportStyleSheet", "Theme"));
   var report = new MyReport(xml);
   return ReportViewer(report);
}
 
private ViewResult ReportViewer(Report report)
{          
   return View("ReportViewer", report);
}

ThemeController
public ActionResult ReportStyleSheet()
{
   var xml = string.Empty;
 
   if (this.Request.IsAuthenticated)
   {
    //replaceDictionary replaces the color schemes
    xml = template.BuildTemplate("ReportStyleSheet.xml", replaceDictionary);
   }
 
   return Content(xml, "application/xml");
         
}


ReportViewer.aspx

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<Telerik.Reporting.Report>" %>
 
<%@ Register assembly="Telerik.Reporting, Version=7.0.13.521, Culture=neutral, PublicKeyToken=a9d7983dfcc261be" namespace="Telerik.Reporting" tagprefix="telerik" %>
 
<%@ Register assembly="Telerik.ReportViewer.WebForms, Version=7.0.13.521, Culture=neutral, PublicKeyToken=a9d7983dfcc261be" namespace="Telerik.ReportViewer.WebForms" tagprefix="telerik" %>
 
<telerik:ReportViewer ID="ReportViewer1" style="height: 700px; width: 100%; margin-bottom: 30px;" runat="server"></telerik:ReportViewer>


<script runat="server">
     
public override void VerifyRenderingInServerForm(Control control)
{
   // to avoid the server form (<form runat="server"> requirement
}
 
protected override void OnLoad(EventArgs e)
{
   base.OnLoad(e);
   try
   {
      var instanceReportSource = new InstanceReportSource();
                 
      instanceReportSource.ReportDocument = Model;
      ReportViewer1.ReportSource = instanceReportSource;
   }
   catch (Exception ex)
   {
      Response.Write(ex.Message);
   }
}    
        
</script>

3 Answers, 1 is accepted

Sort by
0
KS
Top achievements
Rank 1
answered on 26 Feb 2014, 03:28 PM
0
henry
Top achievements
Rank 1
answered on 04 Mar 2014, 03:36 AM
Any response from Telerik about this issue?
0
Stef
Telerik team
answered on 06 Mar 2014, 09:14 PM
Hi Henry,

The issue is not reproducible with the described settings.

Please double-check your security settings and the permissions of the user. Also note that the external style sheets can be added to the report in the controller directly, instead of using parameterized constructor for the report.

As of Q3 2013 we introduced a new viewer that may suit better your MVC project. For more details check the following articles:

I hope this information points you into the right direction.


Regards,
Stef
Telerik

DevCraft Q1'14 is here! Join the free online conference to see how this release solves your top-5 .NET challenges. Reserve your seat now!

Tags
General Discussions
Asked by
henry
Top achievements
Rank 1
Answers by
KS
Top achievements
Rank 1
henry
Top achievements
Rank 1
Stef
Telerik team
Share this question
or