You can use Active Server Pages (ASP) on our servers as standard. This application uses VBScript, for example, to perform a variety of functions. For instance, you can read data from a database, or save data to a database. Or you use ASP to apply a standard or dynamic layout.
Redirecting domains in ASP
Since our system does not enable linking domains at the DNS level, you can link domains using an ASP script. You can find an example of an ASP redirect script below.
<%@ %> <% Response.Status="301 Moved Permanently" Response.AddHeader "Location", "http://www.example.com" %>
You must post these lines in the default.asp text file (substitute example.com with the domain to which you want to have the current domain name forwarded). You must then upload this file to the www-directory.
If somebody visits your domain, he will be automatically forwarded to the other domain. For a temporary redirect you must use a 302 Moved Temporarily HTTP code. Information about this can be found in RFC 2616.
LCID date notation in ASP
The LCID property uses the location identifier number to access information on display format issues, such as currency, date, and time, which are specific to a location or region. The location identifier number uniquely defines a geographic location or region.
For example, the location identifier number for the Netherlands is 1043.
The VEVIDA web servers are US installed, which is why the date is presented in the American format. This format can be modified and displayed in the desired localization by means of the FormatDateTime function.
Information about this is provided at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/vsfctformatdatetime.asp.
The way in which the date is saved in Access is also important. This has nothing to do with the presentation, and can be solved by the function mentioned above. It is wise to save this in the YYYY-MM-DD format. In this way the date is always entered properly in the Access table.
Vevida has written the following example for this:
<%@ LANGUAGE="VBScript" %> <% Option Explicit ' We werken met Nederlandse invoer, hierom zetten we de lcid op 1043 Response.LCID = 1043 Dim path, connStr, conn, sqlQuery path = Server.MapPath("../database/db1.mdb") connStr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source="& path &";" Set conn = Server.CreateObject("ADODB.Connection") conn.open = connStr Dim myDate myDate = Request.Form("datum") If myDate = "" Then myDate = "12-1-2001" '12 januari 2001 End If if Request.Form("set") <> "" Then Dim fDate fDate = Year( myDate ) & "-" & Month( myDate ) & "-" & Day( myDate ) sqlQuery = "UPDATE Table1 Set datum = '" & fDate & "' WHERE id = 1" Response.Write "sqlQuery: " & sqlQuery & "<br /><br /><br />" conn.Execute( sqlQuery ) End If Response.Write "Datum opgegeven via het formulier:<br />" & _ FormatDateTime( myDate, 1 ) & "<br />" Response.Write "myDate: " & myDate & "<br /><br />" Dim RecordSet Set RecordSet = Server.CreateObject("ADODB.Recordset") sqlQuery = "SELECT datum FROM Table1 WHERE id = 1" RecordSet.Open sqlQuery, Conn Dim dbDate dbDate = RecordSet("Datum") Response.Write "datum uit database:<br />" & dbDate & "<br />" Response.Write FormatDate( dbDate, 1) & "<br /><br />" RecordSet.close conn.close Set RecordSet = Nothing Set conn = Nothing %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head><title></title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> </head> <body> <form method="post" action="lcid.asp"> <table> <tr> <td>Datum (dd-mm-yyyy):</td> <td><input type="text" value="<%= myDate %>" /></td> </tr> <tr> <td></td> <td><input type="submit" value="submit" /></td> </tr> </table> </form> </body> </html>
This example uses an (US) Access database called db1.mdb which includes a table called Table1; this table has two fields: id (auto number) and the date field, of the date/time type.
Attention: The example must be placed in D:wwwloginname.comwww or the PATH variables must be modified.
Countering caching of ASP pages
Using the Expires or ExpiresAbsolute methods of the Response object you can prevent your ASP pages from being cached. Internet Explorer is a bit more stubborn. To prevent it from caching data, you can add a few HTTP headers. The example below shows the necessary code.
<% Response.expires = -1 Response.CacheControl = "no-cache" Response.addHeader "Pragma","no-cache" %>
See also the Microsoft support document:
For security reasons, the option of directory listings is switched off on our web servers as standard. If you want a directory listing, you can use the ASP script below to generate it.
The script generates a listing from the stipulated folder, including all subfolders and files, provided the rights are adequate for this. We recommend entering the script in a secure directory. In this way the script has sufficient rights to create a listing of the entire website and third parties cannot retrieve the script.
<%@ LANGUAGE="VBScript" %> <% Response.Buffer="true" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <% ' ASP Directory Listing ' 20051024.1051 - Jan Reilink <email@example.com> ' ' Dit script geeft een directorylisting weer. Het script is voorzien van HTML ' waarmee rekening gehouden dient te worden met eventuele stylesheets. ' %> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>ASP Directory Listing</title> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> <!-- Stylesheet --> <link rel="stylesheet" href="style.css" /> </head> <body> <div id="demoBox"> <h3>Directory index</h3> </div> <% ' Hier kunnen de folders opgegeven worden die weergegeven moeten worden. ' Alle subfolders worden ook weergegeven, indien de rechten toereikend zijn. ' Plaats voor iedere folder een regel: ' ListFolderContents(Server.MapPath("./foldernaam")) ' ' Standaard wordt de rootfolder weergegeven. %> <ul> <% ListFolderContents(Server.MapPath("/")) %> </ul> </body> </html> <% sub ListFolderContents(path) dim fs, folder, file, item, url set fs = CreateObject("Scripting.FileSystemObject") set folder = fs.GetFolder(path) ' Geef de folder en informatie weer. Response.Write("<li><b>" & folder.Name & "</b> - " & folder.Files.Count & " files, ") if folder.SubFolders.Count > 0 then Response.Write(folder.SubFolders.Count & " directories, ") end if Response.Write(Round(folder.Size / 1024) & " KB total." & vbCrLf) Response.Write("<ul>" & vbCrLf) ' Geef eventuele subfolders weer for each item in folder. SubFolders ListFolderContents(item.Path) next ' Geef bestanden weer. for each item in folder.Files url = MapURL(item.path) Response.Write("<li><a href=""" & url & """>" & item.Name & "</a> - " _ & item.Size & " bytes, " _ & "last modified on " & item.DateLastModified & "." _ & "</li>" & vbCrLf) next Response.Write("</ul>" & vbCrLf) Response.Write("</li>" & vbCrLf) end sub ' Converteer een fysiek bestandslokatie naar een URL voor ' hyperlinks. function MapURL(path) dim rootPath, url rootPath = Server.MapPath("/") url = Right(path, Len(path) - Len(rootPath)) MapURL = Replace(url, "", "/") end function %>
Tips and instructions for working with ASP
The use of ASP is no problem on our servers, as we work with Windows 2000 and Windows 2003 systems. ASP is the native web script language on these systems. In this way we use Microsoft’s implementation of ASP; however there are a number of issues that you will need to keep in mind.
In order to offer and continue to offer a proper ASP environment it is a good idea to debug the code on your local (development) computer. A regular desktop PC with a personal web server is sufficient, although your own test server would be ideal, of course. After developing and implementing your ASP site, it is a good idea to test it extensively, for example using the Microsoft Web Application Stress Tool. This tool can be used to find possible weak spots in your ASP code.
In addition, a great deal of information on working with ASP can be found at http://www.aspin.com, http://www.w3schools.com or at http://www.siteexperts.com. These have manuals as well as many practical examples. You can also find many useful sample scripts or ready-to-use scripts here.
You can find tips on the use of ASP here: http://msdn2.microsoft.com/en-us/library/ms972335.aspx. The Web Application Stress Tool is a handy tool that enables you to see whether your ASP scripting is correct: http://www.microsoft.com/technet/archive/itsolutions/intranet/downloads/webstres.mspx.
You can solve many problems yourself by switching off the “friendly” error reports in Internet Explorer. You will then see an error message that states the line in which there is an error in your code instead of the “HTTP 500 error” message.
You can find this option under internet options in the advanced tab.
In conclusion, there are a number of specific issues:
1. We do not recommend using Access97 on our servers, because MDAC (Microsoft Data Access Components) 2.6 and higher no longer properly support this and this may result in regular error messages, especially on busier sites. A better solution is Access 2000 and higher. These problems are not known to occur with this.
2. Pay attention when using database connections. To prevent problems, you must neatly close all connections and record sets after use. This prevents performance problems on your website. It is also a good idea not to open more connections than necessary, and preferably not interfering with each other.
3. Keep Access databases small, compress the database regularly. A large Access database, even only a few MBs, will quickly result in error reports because the full database is loaded in the server’s memory for every call.
4. Use ‘Option Explicit‘. This function is not mandatory, ASP does function without it, but from the point of view of performance it is better to define variables in advance. This function prevents you from overlooking a variable.
5. Use ‘response.buffer=true‘ where possible. The object accelerates the presentation of ASP pages by caching (buffering) them. If the output is buffered, the server will wait to send output to the browser until the entire script has been run through, or until the script calls the ‘flush’ or ‘end’ objects.
6. Do NOT use our server as a test environment! ASP is a powerful tool and its use can cause performance problems if not applied with care. Despite our preventive measures, it would of course be a nuisance if one of our servers encounters problems as a consequence of a poorly programmed ASP page. This is also for your own good.
How would you rate this answer?
Thank you for your feedback!
Something went wrong. Please try again later.