URL Rewriting for certain file types

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
I've implemented a very simple URL rewriter using an HttpModule. It simply
intercepts the url, looks it up in a local config table and redirects the
browser to a different URL.

Of course, this only works for files with extensions that cause them to be
processed by ASP.NET. It doesn't work for file types server by IIS only, e.g.
".jpg".

I believe I can change the machine.config to make "jpg" files go through
ASP.NET but what if I install this app on a "hosted" site where I can't make
changes to the machine.config. Is there any other way to make this happen?
Preferably I also want it to be limited to files in specific folder i.e.
/special/my.jpg will redirect but /images/logo.jpg behaves as normal (to keep
up performance).

Thanks!
 
You can always use a work around using "downloader" approach.
Instead of giving out the direct link to the document. Have it like that

http://www.mysite.com/downloader.aspx?file=my.jpg



Then your downloader.aspx will do what it needs to do, figure out where
my.jpg is residing and the use Response.WriteFile to output file to browser.

The file my.jpg might not even be available through direct download.


George.
 
Then you do not have a choice.
Except on new IIS 7.0, I believe with IIS 7 you can route any HttpRequest
through ASP.NET

George
 
Thanks for George's input.

Hi BillAtWork,

As for all the web document types(the extensions) in ASP.NET web
application, IIS will do the judgement first. That means, if the certain
document extension is not redirected to ASP.NET isapi, ASP.NET won't have
the opportunity to process it. So for our custom ASP.NET httphandler or
httpmodule that want to process a file type(orignially managed by IIS
statically), you have to first redirect it to ASP.NET isapi extension in
IIS virtual directory extension.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.






--------------------
 
Hi,
Thanks for all the advice. I did know about the IIS Application Mappings and
I found a hosting service who will add the required mappings to a hosted site.

Thanks.
 
Thanks for your reply,

This is good news. It is really important that you can can control the
application mapping or someother setting in IIS if you will use some custom
handler(intercept some custom extensions).

Good luck!

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.


-----------------------------------------------------
Subject: Re: URL Rewriting for certain file types
Date: Fri, 26 Oct 2007 06:04:01 -0700
 
Back
Top