Forum Moderators: open

Message Too Old, No Replies

Asp dynamically writing a .html file

write to the stream without saving to the server

         

korkus2000

2:45 am on Apr 5, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Does anyone know if classic asp can dynamically write a .html file without saving it to the server. Can you stream a file down to the browser, anything.html, without anything.html physically being on the hard drive? I hope this makes sense.

txbakers

3:17 am on Apr 5, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If I understand you correctly, the answer would be no. ASP is only a means of generating HTML code. Web Servers need to have a file to serve when a user calls it.

I'm not entirely clear about what you want to do.

cyril kearney

6:27 pm on Apr 5, 2002 (gmt 0)

10+ Year Member



I am not sure what you are really asking but the answer is probably YES.

A files called test.asp containing:
<%
Response.Write "<h1>Hello World</h1>"
%>
will write a file back with the proper http header that will display Hello World in whatever font and size your browser defaults to for the h1 HTML tag.

korkus2000

6:34 pm on Apr 5, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I want to know if you can write a .html file back to the browser like cgi does instead of returning the .asp page.

I would use an asp processing page to create a .html file on the fly and serve it to the browser without using the File System Object to create a physical file.

So the file would exist only in the clients browser and not on the server.

I know it is a strange question. I know how to dynamically create existing asp pages. I just want to know if you can create a ghost page in asp.

txbakers

9:02 pm on Apr 5, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Now I understand better.

Sure, you can do that. The code is Response.Write("whatever") You can put all your HTML information within Response.Write commands.

This would be similar to the PERL print() commands.

korkus2000

10:45 pm on Apr 5, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



How do I specify the name of the document? I don't want it to be an asp page.

txbakers

3:49 pm on Apr 6, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You wouldn't specify the name of the new document. It would be the same name as the document that creates it. Just as in Perl, when you call a cgi script, the URL doesn't usually change since the script generates all the code.

korkus2000

4:50 pm on Apr 6, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I want to create a completely seperate page. With its own unique url. I can create dynamic asp. I want to create a page that only exists in the users browser with its own name.

toadhall

5:01 pm on Apr 6, 2002 (gmt 0)

10+ Year Member



Essentially you want to return a file with the .html extension, not .asp, right?

The closest you can get is to create the html file (via asp), save it, serve it, then delete it.

I've heard some claim they can fudge the file extension without going through this, but I've never seen any evidence.

korkus2000

6:18 pm on Apr 6, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



ya thats what I wanted to know. I didn't think it could be done but I wanted to make sure.

william_dw

11:47 pm on Apr 6, 2002 (gmt 0)

10+ Year Member



Hiya,
There are a few ways to do this,
assuming I understand you correctly, you want the following to happen:
Browser requests www.yoursite.com/page.html

ASP code kicks in & generates content.

Content, appearing to be page.html, streams to browser.

Or to put it another way, the user & search engines think it's a normal .html file.

You can either:
Setup a error document:
Your host can do this easily, essentially you dont ever create a file named page.html, when the server figures out it cant find the page, it(the server) instead serves up an error document. This error document can be an ASP file if you wish, and has no functional differences, apart from the fact that visitors(+spiders) think they are looking at page.html.

-or-

If you have server access,
you just need to associate .html files with the asp interpreter. The latest version of ASP (not .net) can process straight HTML files much quicker than previous versions, so you wont experience any resource drain doing this (ok a little to call the interpreter, it's minimal).

Or start hosting on a linux box with ChilliASP + use mod_rewrite.

HTH,
Dw

korkus2000

12:11 am on Apr 7, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thats what I wanted to know thanks!