Jump to content

How to process ASP-Code in XML pages (IIS 7.5)


Donar

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...