MS XMLHTTP or File System Object to Get Content

V

vunet

The friendly URLs in ASP is the goal of my project. However, in ASP
there is no obvious page mapping as I researched compared to other
languages. What I mean is making www.site.com?page=Home being
www.site.com/home/.
One of the workaround I know is to use MS XMLHTTP request on
www.site.com/home/index.asp page which will get the HTML content of
www.site.com?page=Home. I might replace some folder depth if needed in
resulting HTML.
However, there is another solution of using File System Object to get
the file's content (HTML) and display in the same way.
The question is:
1) which method is most effective (fast)?
2) are there other methods I missed?
Thanks.
 
E

Evertjan.

vunet wrote on 10 jun 2008 in microsoft.public.inetserver.asp.general:
The friendly URLs in ASP is the goal of my project. However, in ASP
there is no obvious page mapping as I researched compared to other
languages. What I mean is making www.site.com?page=Home being
www.site.com/home/.
One of the workaround I know is to use MS XMLHTTP request on
www.site.com/home/index.asp page which will get the HTML content of
www.site.com?page=Home. I might replace some folder depth if needed in
resulting HTML.
However, there is another solution of using File System Object to get
the file's content (HTML) and display in the same way.
The question is:
1) which method is most effective (fast)?
2) are there other methods I missed?
Thanks.

Use:

server.transfer "/myDir/mySubdir/" & request.querystring("page") & ".asp"
 
O

Old Pedant

Evertjan. said:
Use:
server.transfer "/myDir/mySubdir/" & request.querystring("page") & ".asp"

Ummm...you have his request *BACKWARDS*.

He *WANTS* to be able to have customers use the url
http://www.mysite.com/home
(a so-called "friendly" or "REST-ful" url) and have them end up on
http://www.mysite.com/index.asp?page=home

His English is reflecting his native language, I think, but his use of
"friendly url" is the trigger.

From a performance perspective, the only good way to do this in ASP is with
a URL-rewriter ISAPI plug-in for the IIS web server. I don't know of any
free ones, though some aren't very expensive.

If you don't mind a little bit of a performance hit, the easy way to do this
is with a CUSTOM 404 Error Page.

That is, you use an ASP page for your CUSTOM 404 ERROR handler (and this
assumes that your web host *allows* you do do this! most do, but not all)
and it simply "inspects" the value of the problem URL (that is, the
non-existent www.mysite.com/home) and transforms it into the right format,
again using Server.Transfer or Response.Redirect.

Google for "ASP Custom 404" and you'll find plenty of hits to help you.
 
P

p byers

Create a "home" folder in the site
Make the "default.asp" in that folder do the same as the "home.asp"
Pete (Northolt uk)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top