{"record":{"id":"5665bf8d862d8af1","repo":"dotnet/wpf","slug":"sr-pagecontentunsupportedmimetype","errorCode":null,"errorMessage":"SR.PageContentUnsupportedMimeType","messagePattern":"SR\\.PageContentUnsupportedMimeType","errorType":"exception","errorClass":"ApplicationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/PageContent.cs","lineNumber":613,"sourceCode":"            }\n\n            ParserContext pc = new ParserContext\n            {\n                BaseUri = uriToLoad\n            };\n\n            if (BindUriHelper.IsXamlMimeType(mimeType))\n            {\n                XpsValidatingLoader loader = new XpsValidatingLoader();\n                o = loader.Load(pageStream, baseUri, pc, mimeType);\n            }\n            else if (MS.Internal.MimeTypeMapper.BamlMime.AreTypeAndSubTypeEqual(mimeType))\n            {\n                o = XamlReader.LoadBaml(pageStream, pc, null, true);\n            }\n            else\n            {\n                throw new ApplicationException(SR.PageContentUnsupportedMimeType);\n            }\n\n            if (o != null && !(o is FixedPage))\n            {\n                throw new ApplicationException(SR.Format(SR.PageContentUnsupportedPageType, o.GetType()));\n            }\n\n            fixedPage =  (FixedPage)o;\n        }\n\n        #endregion Private Methods\n\n        //--------------------------------------------------------------------\n        //\n        // Private Fields\n        //\n        //---------------------------------------------------------------------\n","sourceCodeStart":595,"sourceCodeEnd":631,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/PageContent.cs#L595-L631","documentation":"_LoadPageImpl throws ApplicationException with SR.PageContentUnsupportedMimeType when the loaded page stream's content type is neither XAML nor BAML (per MimeTypeMapper checks). PageContent only knows how to parse XAML/BAML into a FixedPage.","triggerScenarios":"GetPage/_LoadPage on a PageContent whose Source part has a MIME type other than application/vnd.ms-package.xps-fixedpage (XAML/BAML variants), e.g. an image, HTML, or text part used as page content.","commonSituations":"Hand-built XPS packages where page parts were added with wrong Content-Type metadata; serving pages from a web server that returns the wrong Content-Type header.","solutions":["Ensure the page part is XAML FixedPage content with the correct XPS content type","Fix the part's Content-Type metadata in the package ([Content_Types].xml entry)","If serving remotely, correct the server's Content-Type header for .fpage resources"],"exampleFix":"// before\n// [Content_Types].xml maps .fpage to text/plain\n// after\n// <Default Extension=\"fpage\" ContentType=\"application/vnd.ms-package.xps-fixedpage+xml\" />","handlingStrategy":"validation","validationCode":"var part = pkg.GetPart(PackUriHelper.CreatePartUri(pageContent.Source));\nbool ok = part.ContentType == \"application/vnd.ms-package.xps-fixedpage+xml\";","typeGuard":null,"tryCatchPattern":"try { var p = pageContent.GetPage(); } catch (ApplicationException) { /* inspect part ContentType */ }","preventionTips":["Register correct content types in [Content_Types].xml","Verify server Content-Type headers when serving page parts remotely","Author page parts only as XAML FixedPage"],"tags":["wpf","xps","mime-type","unsupported"],"backgroundTag":"incompatible-source-type","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-21T21:30:21.729Z"}