Donar 0 Posted March 4, 2011 Report Share Posted March 4, 2011 (edited) Dear Forum,Win 7 Ultimate, IIS 7.5 here.How can I have IIS preprocess my .xml pages before I send them to the client? Basically, I want to run my run-at-server scripts like with .aspx files, only that my pages have the .xml extension (and XML content of course).The approach taken so far:I expanded the path on the handler allocation page from old "*.aspx" to new "*.aspx, *.xml" for all three of:PageHandlerFactory-Integrated, PageHandlerFactory-ISAPI-2.0, and PageHandlerFactory-ISAPI-2.0-64.However, I seem to have not enough understanding on how IIS works, as it does not process an XML page containing<%@ Page Language="C#" %>in the first line, but sends it to the client (which correctly complains that this XML is not well-formed).Thanks in advance for your time.Regards,DonarEdit: If this is the wrong board for my help request, I'd appreciate a pointer to the correct one. Thank you. Edited March 4, 2011 by Donar Quote Link to post Share on other sites
boen_robot 107 Posted March 4, 2011 Report Share Posted March 4, 2011 Do you have to use ".xml" as your file's extension? There's no problem in using ".asp" or ".aspx" file extension, and simply setting the Response.ContentType to "application/xml" to make the response be treated as XML regardless of extension. Quote Link to post Share on other sites
Donar 0 Posted March 5, 2011 Author Report Share Posted March 5, 2011 Thanks again for your answer, boen_robot.Well, it is XML content, so I really prefer the .xml extension, I don't like the idea of "pages in disguise" too much.However, I can not really believe, that IIS should not be able to process anything else than .aspx-pages; there surely must be a way to tell it which extensions to handle accordingly.Regards,Donar Quote Link to post Share on other sites
boen_robot 107 Posted March 5, 2011 Report Share Posted March 5, 2011 aspx pages are by definition pages in disguise... an HTML page in disguise.If you use an aspx extension for anything, adding one more use for it should be a no brainer.If you write the extension as a separate entry, you'll make the file be dynamic, but... I'm not sure where do I add the so called "build provider" in order to deal with the new error message that would pop at that case. Quote Link to post Share on other sites
Donar 0 Posted March 6, 2011 Author Report Share Posted March 6, 2011 Thanks for your answer. aspx pages are by definition pages in disguise... an HTML page in disguise.I agree with that one, of course.Anyway, does this mean that IIS just handles pages with an .aspx extension, and that there is no way on preprocessing a page's server-side scripts when there is another extension?Regards,Donar Quote Link to post Share on other sites
boen_robot 107 Posted March 6, 2011 Report Share Posted March 6, 2011 There's probably some sort of setting to tackle the "buildProvider" thing, but I'm not aware of it.You could install and use the RewriteModule to make the URL appear as if it has another extension, but the file itself will still be an aspx file. Quote Link to post Share on other sites
Donar 0 Posted March 7, 2011 Author Report Share Posted March 7, 2011 (edited) There's probably some sort of setting to tackle the "buildProvider" thing, but I'm not aware of it.Thanks for directing me into the right direction.After a lot of research I came up with the following:First I tried to duplicate the entry for the .aspx entension in my site's web.config page. <system.web> <compilation> <buildProviders> <add extension=".xml" type="System.Web.Compilation.PageBuildProvider"/> </buildProviders> </compilation> </system.web> But this alone won't do the trick: everything behaves just like before:both static and dynamic .xml are served without being preprocessed at the server.However, adding this in the system.webServer section: <system.webServer> <handlers> <add name="ASPNETLikeHandler" path="*.xml" verb="GET,HEAD,POST,DEBUG" type="System.Web.UI.PageHandlerFactory" modules="ManagedPipelineHandler" requireAccess="Script" preCondition="integratedMode" /> </handlers> <validation validateIntegratedModeConfiguration="false" /> </system.webServer> eventually *does* the preprocessing! Only that the returned preprocessed page does not get recognized as an XML file anymore by the client's browser, which is a necessity in order to have it transformed with XSLT.Edit:The MIME type page contains for the xml entry: text/xml, but I suspect that this is not what is returned when the page is preprocessed, instead IIS delivers text/html (just a hypothesis). To overcome this, I need to tell the client browser that this is an XML file, which is done server-side by including this line of code at the second line of *all* XML pages: <?xml version="1.0" encoding="ISO-8859-1"?><% response.ContentType="text/xml" %> Thanks for your time.Regards,Donar Edited March 7, 2011 by Donar Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.