Xml issue!

Oct 4, 2009 at 9:35 PM

Hi there!

I am working on a extension, which content act as the source during a page_load of site.master. The result should be creation of a XML file called Addrotator.xml in a Theme.

Please take a look of the source code here:  http://blog.knigge.dk/page/xml-issue.aspx

Everything run as a dream in vs2009, but I get a HTTP 500 on my test server with IIS 6.0 on win2003.
No XML file is written, although the Theme has the same security permissions as  App_Data.

Any help will be appreciated!

Thanks in advance

Poul

Coordinator
Oct 5, 2009 at 10:02 AM

Glancing at the code, I think the problem may be with the MapPath() function call.  You didn't create your own custom MapPath() function, right?

The Server.MapPath() function that is built into .NET is to create a file/path to a physical location on the hard drive.  /blog.knigge.de is the URL to your site, but doesn't have anything to do with the physical file location on the server.  It should probably instead be:

MapPath("~/")

This would return a value looking something like:

d:\inetpub\wwwroot\knigge.dk\

You might need to remove the leading \\ from target_xmlFileName to avoid two backslashes if you also get a backslash from MapPath().

Oct 5, 2009 at 11:42 PM

Hi Ben

Fine guess! You hit the target – I’m on the road again.

What is the reason for this difference? Is it a bug in Visual Studio or what?

This works in Visual Studio:
target_xmlFileName =” \\themes\\Triathlon\\Addrotator.xml”
mySite = MapPath("/blog.knigge.dk")

This works on the IIS:
target_xmlFileName =” themes\\Triathlon\\Addrotator.xml”
mySite = MapPath("~/")

In both cases holds target_xmlFileName = mySite + target_xmlFileName
the same value – “C:\\Inet\\wwwroot\\website\\blog.knigge.dk\\themes\\Triathlon\\Addrotator.xml”

Anyhow Ben, Many thanks

Poul