How Apache will recognize that a request is from ASP or PHP script
Usually by file extension.
For example in apache you should have lines like that:
<IfModule mod_php5.c>
<FilesMatch "\.ph(p3?|tml)$">
SetHandler application/x-httpd-php
</FilesMatch>
</IfModule>
You can look at the HTTP Response header field "Server" which will tell you something like Server: Apache/2.4.1 (Unix)
Furthermore, ASP.NET supplies a non-standard header along the lines of X-Powered-By:ASP.NET and I know PHP does the same thing (although I can't find the actual message presently.) Bottom line is look at the HTTP response headers.
http://en.wikipedia.org/wiki/List_of_HTTP_header_fields
I should add that none of these will tell you with 100% certainty (Unix could be running some other server side language in the former example; custom headers can easily be suppressed or even spoofed on the latter example) but it would give you a fairly confident guess as to what you're looking for.