Is it possible to return to the web client a page named differently than the original classic asp page read from the web servers folder ?
F.i. a real example I would like to implement: let's say I have an classic asp called
calendar.asp
If this page is called today (Jan 6, 2010) the page returned to the client web site should be:
calendar-of-january-6-2010.asp
If the same page should be called tomorrow, the page returend to the client web site should be:
calendar-of-january-7-2010.asp
You get the picture. Based on some internal logic, return a specific named classic asp page to the web client .
Thanks for any input you might provide.
UPDATE: The specific date files in the above example do not exist phy开发者_如何学JAVAsically (or I could use a redirect). I was hoping to find something like I use to return a csv file:
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader "Content-Disposition", "attachment; filename=export.csv"
Not the same, of course, cause this will let the client browswer prompt for the save/open box. Just something similar.
OK, seen your edit about wanting to link to daily calendars.
Think of it like this:
- Build your pages so that the links are to friendly URLs - /calendars/jan-01-2010.asp, /calendars/jan-02-2010.asp, and so on.
- Configure IIS to use a custom 404 error for /calendars/ - so that whenever a client requests a page here that doesn't exist, your server will run calendar.asp (instead of just sending back "404 Page Not Found")
- That's it. Your client will never see the URL "calendar.asp", because they're never requesting it. All they're doing is following the friendly links you're giving them. It's your server that's doing the clever bit (catching the "invalid" requests, and pretending there's actually a valid page at that URL)
StackOverflow works like this - it uses ASP.NET MVC and the ASP.NET routing engine to intercept those friendly-looking question URLs, look them up in the database, and return a generated page, so that to users (and search engines) it looks like there are thousands of friendly-named pages, when it's actually all happening behind-the-scenes.
You could write a custom ISAPI filter (C++), to control which physical file gets mapped to the URL. You need admin access to the IIS box(es) to install this filter, and if you really want your custom URLs to feature the .asp extension, your filter needs to accomodate this (since ISAPI filters are primarily selected based on extension by IIS). Check this and this MSDN link. This codeproject sample contains some more pointers (it remaps .chm to .asp files, easy to follow).
You can just redirect to the new page from calendar.asp. When user requests this new page use URL rewriting to rewrite back to calendar.asp internally.
Not so good - on first request to calendar.asp generate the actual page (the one with the date) (don't forget to delete it in 24 hours) and redirect to this page.
精彩评论