tags:

views:

97

answers:

3

I'd like to store the contents of classic ASP pages in a table in a database, and have the ability to dynamically retrieve said contents and execute on the fly. Is this possible?

+2  A: 

You can get the text from the database, save it to a temporal .asp file in the website, and then execute a Server.Execute(tempfile). Don't forget to delete the tempfile...

Rodrigo
+1  A: 

You are probably looking for the "Execute" statement.

Dim aspCode
aspCode = getCodeFromDB() ' I assume you can handle this part
Execute aspCode

This will even work if your db-driven ASP has "Option Explicit" at the very top.

That said, the general idea of having ASP code live inside a database sounds a bit iffy to me, but to each their own, and I wish you luck!

Chris Nielsen
Actually, Execute doesn't work. Server.Execute against a path, on the other hand, does work.
NoCarrier
Execute will execute actual VB Script. However an ASP file that has inline <% and %> as well as HTML markup will not work. I have about a BILLION legacy asp reports that i need to archive and control access to. Much easier to corrale them in a DB than to modify each file.
NoCarrier
A: 

Somebody was able to make the Execute (actually ExecuteGlobal) concept work. I tried using this some years ago as a test and it did indeed work. I believe the real problem would come when you want to debug inside your 1000 line ExecuteGlobal statement.

http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=7651&amp;lngWId=4

Basically, the asp text is parsed and items within <%=%> and <% %> are handled appropriately.

For instance

    <%=var1 & "-" & var2%> 
would convert to
    response.write var1 & "-" & var2

and

  <%
  Hello, this is html
  %>
would convert to 
  response.write "Hello, this is html"
pflunk