Thursday, February 05, 2004

IIS: happy to put your server in a loop

Just found this peace of documentation in the IIS Help files. Imagine what would happen if, for the one or other reason the HTTP_ACCEPT_LANGUAGE server variable would not be known... The welcome.asp file would include itself :) Better use welcome.asp, and something like Lang & ".asp" for each language. And default back to English when the above mentioned variable is empty.



Welcome.asp

<HTML>

<BODY>
<H1>Company Name</H1>
<%
AcceptLang = Request.ServerVariables("HTTP_ACCEPT_LANGUAGE")
Lang = Left(AcceptLang, 2)
Server.Execute(Lang & "Welcome.asp")
%>
</BODY>
</HTML>


enWelcome.asp
<% Response.Write "Welcome to my website!" %>



deWelcome.asp
<% Response.Write "Willkommen zu meinem website!" %>



esWelcome.asp
<% Response.Write "RecepciĆ³n a mi website!" %>