views:

256

answers:

2

I have a web application that lands on a shared hosting platform for my company. That platform has global header/footer code that all applications on the platform consume using include files. I can't change how the header files are structured and how they are to be cosumed--that is dictated to me by another group. I have a build server that does not has IIS installed by design. I am attempting to use the aspnet_compiler.exe during the build process to generate the precompiled website files for deployment.

However, when the build runs I get errors like this:

/Company/Controls/Header.ascx(7): error ASPPARSE: Failed to map the path '/sites/header.inc'.

The Header.ascx control has this server-side include in the HTML:

<!-- #include virtual="/sites/header.inc" -->

On my local machine, I have created a virtual directory in IIS named "sites" that points to the global header code (which I have also copied to my local machine). This same "sites" virtual exists in IIS on the hosting environment. I would really like to avoid having to install IIS on the build machine because it is a shared build machine and I don't anyone to mistakenly work IIS dependencies into their code. The build machine shouldn't need to have IIS.

What is the best way to get the precompiled site files that aspnet_compiler.exe produces during my build without installing IIS?

A: 

Don't use server-side includes. They are ancient technology and are disabled on most modern sites.

I recommend you instead create .ascx files to replace each of the .inc files, and use those instead.

John Saunders
I agree that .inc files are outdated, but this response doesn't answer the question--as I mentioned, I can't change the structure of how the files are provided. Given that I can't change the structure, how can I get pre-compiled site files?
Shawn
I don't see why you would expect this to work. .inc files are used by IIS aspnet_compiler has nothing to do with IIS.
John Saunders
+1  A: 

Microsoft has a very simple example of how to replace an include statement...

http://support.microsoft.com/kb/306575

Looking at the path of your error it seems you are already using some sort of global user control and I'm guessing this is a file which is reused by other applications or languages so I would suggest coming up with a more custom version with error handling and such since it is working over a mapped drive but the basic answer is you need to read the file and output it to the stream during the Render event.

JKG
A detail I did not mention is that the .inc file I reference--and which I can't control or restructure into a better format--has nested server-side includes. So if I do what you suggested, it works, but I only get the topmost inculde and any nested server-side includes are lost. I am looking for answers that work with the .inc file situation that I listed as a "given" to this problem rather than attempting to replace the .inc file with something else.
Shawn
As stated earlier server-side includes are frowned upon but it is possible to make IIS handle them for any file type. I haven't tried this with nested includes before and it will have an impact on performance but...http://tim-stanley.com/post/How-To-Enable-HTM-Server-Side-Include-Parsing-in-IIS.aspxhttp://msdn.microsoft.com/en-us/library/ms525940.aspxAnother option would be to create a custom control which can read an include;,parses and then reads each nested include, then caches it with a file change dependency, much more tricky and error prone but will work.
JKG