I am making my website about a radio station, and it's currently PHP-based, but I am testing an ASP-based one on my dev machine.

This is the PHP querystring code:

<?
$i=$_GET['DJID'];
switch ($i) {
case 1:
    include("dj1.php");
    break;
case 2:
    include("dj2.php");
    break;
case 3:
    include("dj3.php");
    break;
default:
    echo "page not found!!!!";
}
?>

Using that produces:

(this is a virtual host mapped via httpd.conf and
however, I've now got Apache as a reverse proxy, so I can map to ASP sites too on my IIS!)

I want to try and replicate this into my other version, which is at
(mapped using the httpd.conf and reverse proxy method!)

I would like to know what the ASP equivalent is for this, as I have tried to get querystrings working, but only at the most basic level for ASP - I'm having to learn this so I can ensure I'm competent in both for my website design/management skills!

Please can anyone help me with the ASP code for this one?

Thanks! :)

Dani AI

Generated

asked how to replicate the PHP querystring include pattern in ASP. There are two common approaches depending on whether you mean classic ASP (VBScript) or ASP.NET (Web Forms). Below are concise, safe patterns and a few quick diagnostics for the Apache reverse-proxy setup you described.

Classic ASP (VBScript) — include at runtime:

<%
Dim id
id = Request.QueryString("DJID")
Select Case id
  Case "1"
    Server.Execute("dj1.asp")
  Case "2"
    Server.Execute("dj2.asp")
  Case "3"
    Server.Execute("dj3.asp")
  Case Else
    Response.Write "page not found!!!!"
End Select
%>

Notes: <!--#include--> cannot use dynamic filenames; use Server.Execute to run another ASP file and include its output. Always validate id (whitelist acceptable values) to avoid path traversal or injection.

ASP.NET Web Forms (C#) — load a user control dynamically:

protected void Page_Load(object sender, EventArgs e)
{
    string id = Request.QueryString["DJID"];
    switch (id)
    {
        case "1":
            PlaceHolder1.Controls.Add(LoadControl("~/dj1.ascx"));
            break;
        case "2":
            PlaceHolder1.Controls.Add(LoadControl("~/dj2.ascx"));
            break;
        default:
            Response.Write("page not found!!!!");
            break;
    }
}

Notes: In ASP.NET you typically use UserControls (.ascx) or separate pages and either load a control into a placeholder or redirect/transfer. Use int.TryParse or a whitelist to validate the query value.

Troubleshooting the reverse-proxy: confirm the querystring reaches IIS by hitting the backend directly (port used by IIS) or add a tiny test page that writes Request.QueryString/QUERY_STRING. If you use mod_rewrite, ensure the QSA flag is used so the original querystring is preserved. Check Apache and IIS logs to see whether the query string is present.

My httpd.conf entry for this site:

NameVirtualHost *:80

<VirtualHost *:80>
    ServerName localhostradiostation2.co.uk
    ServerAlias www. localhostradiostation2.co.uk
    DocumentRoot C:\inetpub\wwwroot\localhostradio2
    DefaultType text/html
    <Directory "C:\inetpub\wwwroot\localhostradio2">
        Options Indexes FollowSymLinks
        AllowOverride none
        Order allow,deny
        Allow from all
    </Directory>
    # sends all requests made to port 80 to another port 8080
    ProxyPass / [url]
    #makes proper changes to server-side redirection header
    ProxyPassReverse / [url] 
</VirtualHost>

That's the relevant extract from the httpd.conf mappings.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.