0

I have .html file with asp code inside.

<html>
<body>
<%
Request.write("hello")
%>
</body>
</html>

and this prints <% Request.write("hello") %>

I believe ASP is activated because it works when I renamed it to test.asp.

But What I'm trying to do is to encapsulate the asp code inside of html file.

David
  • 208,112
  • 36
  • 198
  • 279
  • 2
    shouldn't it be `Response.write("hello")`? – Rahul Aug 25 '16 at 18:27
  • 1
    html doesn't "read" anything. IN a properly functioning system. the asp code would NEVER reach the client. you can't expect the remote browser to know what the heck asp code is - the entire universe isn't just microsoft servers and browsers. – Marc B Aug 25 '16 at 18:31
  • If you want ASP files to be processed when they have a `html` extension you need to add a HTTPHandler into IIS or modify the existing one to work with both `asp` and `html` extensions. – user692942 Aug 25 '16 at 21:03
  • If you are missing the Handler mappings this will describe how to set them up - [ASP Classic setup issues](http://stackoverflow.com/a/22194273/692942) – user692942 Aug 26 '16 at 08:11
  • Possible duplicate of [ASP Classic setup issues](http://stackoverflow.com/questions/22186052/asp-classic-setup-issues) – user692942 Aug 26 '16 at 08:18
  • It's perfectly valid to use both server side VBS and client side html within a file with an asp extension - embedding server side code within html is the whole concept of asp. The .html extension however, is almost always used for files with client side code only, and it's best to leave it that way unless you have a very specific reason not to. – John Aug 27 '16 at 13:56

1 Answers1

2

I believe ASP is activated because it works when I renamed it to test.asp.

Then rename the file to test.asp.

By default server-side code is processed in .asp files, not .html (or any other) files. Ideally, you don't want to change that as it adds a lot of unnecessary overhead to the web server. You can configure the web server (depending on the web server) to also process other file types, but again it's not recommended.

Additionally, I believe you meant this:

Response.write("hello")

Writing to the request doesn't really make much sense.

David
  • 208,112
  • 36
  • 198
  • 279