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:
ReportController
ThemeController
ReportViewer.aspx
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>