0

I wrote this HTML form and I'm trying to process it in asp using POST, so that as soon as I submit the form, it should show the data that I submitted in the HTML form.

The HTML form works fine, but whenever I click on submit, It doesn't show what I've submitted, it just shows the ASP code that I wrote. I don't know what I'm doing wrong. anyone got an idea?

This is my HTML code

<!DOCTYPE html>
<html>
    <head>
        <title>HTML Forms!</title>
        <link href="buy.css" type="text/css" rel="stylesheet" />
    </head>

    <body>

        <h2>Give Us Your Money</h2>

        <form method="post" action="validate-ex2.asp">
        First Name: <input type="text" name="fname"><br><br>


        Card Number: <input type="text" name="cnumber"><br><br>

    <legend>Credit cards:</legend>
    <input type="radio" name="cc" value="visa"  checked="checked" /> Visa
    <input type="radio" name="cc" value="mastercard" />     MasterCard
<br><br>
<input type="submit" value="Submit"> <br>

        </form>

    </body>
</html>

And this is my ASP code

<html>
<body>

<%
dim fname
fname=Request.Form("fname")

Response.Write("First Name: " & fname & "<br>")
%>

</body>
</html>

I tried everything here, here and here but still same error, I hope I haven't messed up anything by doing what was described there

EDIT: Here's an image of the output while trying to run a simple HTML code that includes ASP-classic Trying to run ASP

Steinhammer71
  • 105
  • 1
  • 2
  • 7
  • @Greg It is actually my first ASP code to write, so I don't really know. I have the IIS already enabled/activated in the Windows features. Do you think that those 2 files should be in the ```C:\inetpub``` folder? – Steinhammer71 Dec 16 '20 at 20:17
  • You tagged this as ASP.NET. Why? And...if you're actually using classic ASP....why? That's decades old technology. – mason Dec 16 '20 at 20:50
  • @mason because I don't have enough reputation to tag "ASP" alone, sorry, and I'm using it because I'm trying to write few codes using classic ASP – Steinhammer71 Dec 16 '20 at 20:56
  • @Greg I tried placing those files into ```C:\inetpub\wwwroot\``` but same problem. still when I click on ```Submit``` it shows the ASP code Anyway, does the ASP code look correct to you? or there's something wrong with it? – Steinhammer71 Dec 16 '20 at 21:01
  • The correct tag to use would be `asp-classic` which I've now tagged for you. Even with your current reputation, you would have been able to do that as well. Now....why are you writing new ASP logic in 2020? – mason Dec 16 '20 at 21:04
  • @mason thank you (even though I searched for ASP, but the classic one didn't appear, weird). Because my supervisor is super old fashioned and isn't modern enough to provide newer technologies. – Steinhammer71 Dec 16 '20 at 21:07
  • @Steinhammer71 Well you can point out to your supervisor that ASP classic isn't supported anymore. It's not receiving security updates, and leaves the company vulnerable to attack and lawsuits. And it's just an inefficient and hard to maintain way of writing apps. So if they want that on their conscious... Good luck to you. – mason Dec 16 '20 at 21:09
  • @mason I did, and he knows it's super old. Even though he knows those things, and still all of his work is with ```ASP-classic``` he still never wants to change. thank you anyway. – Steinhammer71 Dec 16 '20 at 21:13
  • Does this answer your question? [How to enable ASP classic in IIS7.5](https://stackoverflow.com/questions/9072048/how-to-enable-asp-classic-in-iis7-5) – user692942 Dec 16 '20 at 21:58
  • @Lankymart I tried enabling everything, but it still shows the same output, I tried running a ready ASP-classic code from w3schools, and it showed the same output (it printed the ASP code out) could be something else on my PC that I have to activate or enable? – Steinhammer71 Dec 16 '20 at 23:32
  • Are you using IIS?, if you are have you installed "Active Server Pages" from the Windows Features in Windows 10 or from Server Features. It sounds like the ASP part of IIS isn’t installed. So not sure you’ve tried **everything**. – user692942 Dec 17 '20 at 00:04
  • @Lankymart here https://i.imgur.com/87LSfDl.png and here https://i.imgur.com/1zsD19L.png Please tell me if anything is wrong, because tbh, I don't know how to fix this, or if what I did is correct or not – Steinhammer71 Dec 17 '20 at 00:13
  • If you want to display the posted data in the form you need to either handle the post in the same page or redirect back to the original form page passing parameters in the query string – Jon P Dec 17 '20 at 00:57
  • @Steinhammer71 have you checked the [handler mappings](https://stackoverflow.com/a/22477210/692942) - Keep in mind 32 vs 64 bit as well mentioned in the answer? – user692942 Dec 17 '20 at 08:03
  • 1
    Does this answer your question? [I have already enabled classic asp support on IIS for windows 7, and configured IIS web for classic asp,Yet .asp page is not being displayed?](https://stackoverflow.com/a/22477210) – user692942 Dec 17 '20 at 10:05
  • @Lankymart I already did what was mentioned there regarding the handler mapping, but still it would show the raw code of ASP... seems like this is going nowhere and I won't be able to fix it – Steinhammer71 Dec 17 '20 at 11:19
  • 2
    Well it expects you to be using an existing website setup in IIS, ASP doesn’t just magically start preprocessing the script from anywhere on your file system. By default IIS has the "Default Website" setup to run on http://localhost:80, which is associated to the C:\inetpub\wwwroot folder. – user692942 Dec 17 '20 at 13:28

1 Answers1

0

Apparently I had to move my ASP and HTML file to the C:\inetpub\wwwroot\ folder, but not only this. I tried running them from there as well, but still it would show the raw code. what I did first, was enabling other Windows Features (that I saw somewhere online).

This actually could've been the fix from the beginning but running the html or the asp code directly from the C:\inetpub\wwwroot\ shows the raw ASP code, I just had to type localhost/[filename].html or whatever in the browser and also modifying the permissions by adding Everyone and allowing full control and modify to the folder inside inetpub or the files themselves...

Sorry if you guys thought I was doing that from the beginning, but now it works just fine. Thanks for your help!

Steinhammer71
  • 105
  • 1
  • 2
  • 7
  • Seems you had some key gaps in how to use Classic ASP in IIS and how it’s designed to work. – user692942 Dec 17 '20 at 13:30
  • @Lankymart yea I did, never thought it would be that way to run a code lol. and thanks for your help. – Steinhammer71 Dec 17 '20 at 13:36
  • FYI you don't actually need to move your code to "C:\inetpub\wwwroot\". That's the location of the default website, but once you've played with IIS Manager for a bit you'll discover that you can create other websites and map any directory you choose as your root folder. (You can even remap the root of the default site to a different folder) – John Dec 18 '20 at 17:57
  • @John Thanks for letting me know! didn't know this was possible. – Steinhammer71 Dec 19 '20 at 15:25