Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 243
  • Last Modified:

How do i set up IIS to serve dynamic xml

I have a web page that builds some xml and sends it to the requester.  Right now this page is called xmlData.aspx and it works perfectly.  

Now i would like this file to have a .xml extension so i placed it in a sub directory, renamed it to have a .xml extension, made that directory an application in iis and set the application mapping for .xml files to be the same as .aspx files (c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll for .xml, verbs GET,HEAD,POST,DEBUG), and restarted IIS.  Apparently this was not enough to make it do what i wanted because when i hit myPage.xml it sends back simply
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="myPage.aspx.cs" Inherits="myPage" %>

which is the entirity of myPage.xml, not interpreted by aspnet_isapi.dll as the .aspx version was.

What am i doing wrong?
0
dave4dl
Asked:
dave4dl
  • 3
  • 3
1 Solution
 
abelCommented:
You just need a tad bit more. I just tried it for myself, for some bogus extenstion .abab, and it worked well. What you need is:

  1. Add Script Map (see first screenshot)
  2. Fill the request path with *.xml and the executable with the aspnet_isapi.dll (see second screenshot)
  3. Set the name to whatever you like, click ok and click yes to confirm
  4. Add a Managed Handler (see first screenshot)
  5. Fill in like in third screenshot, use System.Web.UI.PageHandlerFactory for the type and set the request path equal like the script map: "*.xml"
  6. Set the name to whatever you like, click ok and click yes to confirm
  7. Go to the web page and test, sometimes it is already correct now. But likely: not. One last thing needs to be done:
    1. Go to your web.config (or global web.config)
    2. find the section on <compilation>
    3. on the same level as the assemblies, add a buildProvider for *.xml (see below in the code snippet)
  8. Go test your page. It should work now
If you still have any problems, tell me what error you got and we take it from there. It is probably a good idea to remove any current handlers for *.xml, if any.

-- Abel --


<compilation debug="true">
	<assemblies>
		<add assembly="System.Core, Version=3.5.0.0.... />
		<add assembly="System.Data.DataSetExtension.... />
		<add assembly="System.Web.Extensions, Versi.... />
		<add assembly="System.Xml.Linq, Version=3.5.... />
	</assemblies>
        <!-- copy this part on buildproviders -->
	<buildProviders>
		<add extension=".xml" type="System.Web.Compilation.PageBuildProvider"/>
	</buildProviders>
</compilation>

Open in new window

ScreenShot223.png
ScreenShot224.png
ScreenShot225.png
0
 
dave4dlAuthor Commented:
Thanks for such a thorough and clear response abel.  I completely forgot to mention which version of IIS i am using.  The directions you posted were for IIS 7 and i am using IIS 5.5 (windows xp).  Would you mind telling me how to do this in 5.5?  I thought maybe the web config was the piece i was missing so i added the below web.config to my application folder but I still get the same thing (the server side page is transmitted with no interpretation)

I am posting pictures of the steps i have followed so far (after which i do an iisreset).  Any thoughts?
<configuration>
  <system.web>
    <compilation debug="true">
      <buildProviders>
        <add extension=".xml" type="System.Web.Compilation.PageBuildProvider"/>
      </buildProviders>
    </compilation>
  </system.web>
</configuration>

Open in new window

step1.bmp
step2.bmp
step3.bmp
0
 
dave4dlAuthor Commented:
i'm sorry, for step 1 i accidentally uploaded the wrong file (which i could not see until the actual post was done).  The correct one is attached to this post
step1.bmp
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
abelCommented:
I'm not sure, but *.xml is a registered MIME type. If i'm not mistaken, you need to remove the registered MIME type for the server, otherwise the server will recognize it as a valid file and server is accordingly.

Note that you can only remove registered MIME types on a global level. On a local level you will have to add these MIME types to the other virtual directories and web servers if you want them to act normally to an *.xml request.
0
 
abelCommented:
Btw: I'm a bit guessing here, I haven't used IIS 5.5 (other than some maintenance with older clients) for many many years, so I do this by heart now... ;)
0
 
dave4dlAuthor Commented:
thank you for your help!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now