DTD prohibited in xml document exception
Note that settings.ProhibitDtd is now obsolete, use DtdProcessing instead: (new options of Ignore, Parse, or Prohibit)
XmlReaderSettings settings = new XmlReaderSettings();
settings.DtdProcessing = DtdProcessing.Parse;
and as stated in this post: How does the billion laughs XML DoS attack work?
you should add a limit to the number of characters to avoid DoS attacks:
XmlReaderSettings settings = new XmlReaderSettings();
settings.DtdProcessing = DtdProcessing.Parse;
settings.MaxCharactersFromEntities = 1024;
DTD is prohibited exception when transforming XML file
If the XSLT uses or references a DTD, pass an XmlReader with the necessary XmlReaderSettings to the Load method, i.e. use the overload https://learn.microsoft.com/en-us/dotnet/api/system.xml.xsl.xslcompiledtransform.load?view=netframework-4.8#System_Xml_Xsl_XslCompiledTransform_Load_System_Xml_XmlReader_ with
using (XmlReader xsltReader = XmlReader.Create(xsltPath, new XmlReaderSettings() { DtdProcessing = DtdProcessing.Parse }))
{
transformObj.Load(xsltReader);
}
DTD is prohibited in this XML document
You shouldn't download the schema from the server every time your program runs. You should download it once and keep it on your hard drive.
I think this will also take care of the “protocol violation” error.
Related Topics
C# - Making All Derived Classes Call the Base Class Constructor
Count Number of Mondays in a Given Date Range
Change File Extension Using C#
Get Ipv4 Addresses from Dns.Gethostentry()
Any Way to SQLbulkcopy "Insert or Update If Exists"
C# ASP.NET Write File to Client
Add Vertical Scroll Bar to Panel
How to Convert Date Format to Dd-Mm-Yyyy in C#
Regex Word Boundary Expressions
How to Serialize and Save a Gameobject in Unity
Save Modified Wordprocessingdocument to New File
Executenonquery Doesn't Return Results
JSON.Net: Specify Converter for Dictionary Keys