Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / October 2007

Tip: Looking for answers? Try searching our database.

URL Rewriting for certain file types

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
BillAtWork - 25 Oct 2007 15:22 GMT
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!
George Ter-Saakov - 25 Oct 2007 16:41 GMT
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.

> Hi,
> I've implemented a very simple URL rewriter using an HttpModule. It simply
[quoted text clipped - 16 lines]
>
> Thanks!
BillAtWork - 25 Oct 2007 17:07 GMT
Unfortunately I can't implement it that way because the requests are coming
from external systems. They don't want to implement a special format just for
this app. It has to be:

http://www.site.com/special/aaa.jpg
http://www.site.com/special/bbb.jpg
etc.

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
[quoted text clipped - 28 lines]
> >
> > Thanks!
George Ter-Saakov - 25 Oct 2007 18:05 GMT
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

> Unfortunately I can't implement it that way because the requests are
> coming
[quoted text clipped - 49 lines]
>> >
>> > Thanks!
Steven Cheng[MSFT] - 26 Oct 2007 07:08 GMT
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.

--------------------
>From: "George Ter-Saakov" <gt-nsp@cardone.com>
>Subject: Re: URL Rewriting for certain file types
>Date: Thu, 25 Oct 2007 13:05:54 -0400

>Then you do not have a choice.
>Except on new IIS 7.0, I believe with IIS 7 you can route any HttpRequest
[quoted text clipped - 55 lines]
>>> >
>>> > Thanks!
BillAtWork - 26 Oct 2007 14:04 GMT
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 George's input.
>
[quoted text clipped - 83 lines]
> >>> >
> >>> > Thanks!
Steven Cheng[MSFT] - 29 Oct 2007 03:53 GMT
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

>Hi,
>Thanks for all the advice. I did know about the IIS Application Mappings and
[quoted text clipped - 89 lines]
>> >>> >
>> >>> > Thanks!

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.