开发者

Returning RDF from Controller Action - ASP.NET MVC

I have a controller action that returns a RDF document as XML to the browser. The browser complains that the document cannot be displayed:

Th开发者_如何转开发e namespace prefix is not allowed to start with the reserved string "xml". Error processing resource

I was attempting to use MCVContrib's XMLResult object to write the document out to the response stream. How can I have this document displayed correctly to the browser? Do I have to resort to writing a plain string?

 public ActionResult Content(string id, string version, string localization)
    {
        IDocumentRequest request = new ResourceRequest()
                                       {
                                           Id = id,
                                           Localization = Localization.GetByName(localization),
                                           Version = version
                                       };

        XmlDocument doc = _kbModel.GetContent(request);

        return new XmlResult(doc);
    }


RDF has a different MIME type thank just XML. XMLResult will set the MIME type to "application/xml" and what is needed by RDF is "application/rdf+xml". You need to set this manual or you can create your own ActionResult that sets it.

SEE: http://www.w3.org/TR/rdf-syntax-grammar/#section-MIME-Type


You have an xml namespace (as 'xmlns:xml="..."') at the root of your returned document.

OR

You are using an old Microsoft XML (MSXML) parser equal to Microsoft XML Core Services version 4.0 or lower. Update to the last version of MSXML.

Reason: You are using one/some of Microsoft XML (MSXML) keywords in your namespace prefixes in the returned XML document, i.e xml,

For example you have a namespace like xmlMyProject in returned xml document. Note that xml capitalization doesn't matter, i.e. XMLMyProject, XmlMyProject...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜