472,785 Members | 1,152 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,785 software developers and data experts.

How to rewrite urls without having access to IIS MMC

Hi,

I am using a asp.net hosting service and I don't have access to IIS MMC.

I would like to implement a URL rewriting service so all urls with shape:

http://domainname.com/nnnn.jpeg

get redirected to:

http://domainname.com/images/ImageHandler.aspx?n=nnnn

Can I do that just by using web.config?

Any link to url re-writing article would be a great help.

Regards,
Max
Nov 6 '06 #1
2 1748
Hi Max,

Unless I'm mistaken, I don't think it's going to be possible to do this
exactly as you want. The main problem is that files with extensions
like .jpeg or .gif are not handled by the ASP.Net engine. In other
words, the ASP.Net part of the server won't have any idea that a
request for one of these pages has been made.

If you had your own server, you could change this behavior and have
requests for .jpeg files handled by ASP.Net. However, I seriously doubt
that your hosting provider would be willing to set this up.

The next best option is to use a "custom HTTP handler", which is a
special ASP.Net page with the extension .ashx. In fact, your
ImageHandler.aspx page should really be a .ashx page, but you'll
probably get away with doing it either way.

I highly recommend using www.urlrewriting.net to do the re-writing.
ASP.Net 2.0 does allow you to do some basic re-writing, but it doesn't
let you use regular expressions or wildcards so you'd have to write a
separate rule for every single image file. Once you've downloaded
UrlRewritingNet, you'll be able to re-write URLs with a certain "shape"
just as you want.

However, what you MUST remember is that you can't re-write .jpeg files
without getting access to the IIS MMC. Instead, you'll need to re-write
files that match "/blah.ashx" to "/images/ImageHandler.ashx?n=blah". In
your web.config, this means having something like this for the
UrlRewritingNet configuration...

<urlrewritingnet rewriteOnlyVirtualUrls="true" compileRegex="true"
xmlns="http://www.urlrewriting.net/schemas/config/2006/02" >
<rewrites>
<add virtualUrl="^~/(.*).ashx"
destinationUrl="~/images/ImageHandler.ashx?n=$1" />
</rewrites>
</urlrewritingnet>

I hope this helps! Once you get it working it's great.

Phil
Max2006 wrote:
Hi,

I am using a asp.net hosting service and I don't have access to IIS MMC.

I would like to implement a URL rewriting service so all urls with shape:

http://domainname.com/nnnn.jpeg

get redirected to:

http://domainname.com/images/ImageHandler.aspx?n=nnnn

Can I do that just by using web.config?

Any link to url re-writing article would be a great help.

Regards,
Max
Nov 6 '06 #2
Hi Max,

I'm afraid that's not possible to rewrite a path ended with an extension
that is not mapped to ASP.NET engine in IIS. If you take a look at an
ASP.NET web site's "Application Settings" in its IIS property page (click
on "Configuration" button to see the Application Mappings), you will see
extensions such as .aspx, .config are mapped to use aspnet_isapi.dll. For
extensions are not mapped, IIS will serve them directly. Since you're
asking how to rewrite the path of a .jpeg file, which is normally not
mapped, I think it cannot be done.

For extensions do mapped to ASP.NET, you can find a URL rewriter
implementation here:

#URL Rewriting with ASP.NET - The Code Project - ASP.NET
http://www.codeproject.com/aspnet/URLRewriter.asp
Demonstrates the use of regular expression-based URL Rewriting, similar to
mod_rewrite with ASP.NET

Sincerely,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your reply
promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

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

Nov 6 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Az Tech | last post by:
Hi people, (Sorry for the somewhat long post). I request some of the people on this group who have good experience using object-orientation in the field, to please give some good ideas for...
0
by: Paul Hatcher | last post by:
I'm using a url rewriting mechanism to make my site's urls more search-engine/user-friendly, so we have http://www.mysite.com/links/1023.apx which is actually internally mapped to...
9
by: Paul Hatcher | last post by:
Sorry to post this again - I didn't use my MSDN alias previously... I'm using a url rewriting mechanism to make my site's urls more search-engine/user-friendly, so we have...
5
by: frizzle | last post by:
Hi group, I know this isn't the right group, but i didn't know what group else it should be. I have a php/mySQL system, wich uses mod rewrite to enhance urls. I have the following...
1
by: baroque Chou | last post by:
Thanks for the help available on msdn, I have succesful done the rewrite job. But there are 2 problems arise: 1.when I try to rewrite the url from say: www.yoursite.com/beverages.aspx to...
1
by: Miguel Isidoro | last post by:
Hi all, I am developing a ASP.NET 2.0 application that must use friendly URLs. As an example, a content in http://www.mysite.com/music/pearljam for instance should be rewritten to...
10
by: jflash | last post by:
Hello all, I feel dumb having to ask this question in the first place, but I just can not figure it out. I am wanting to set my site up using dynamic urls (I'm assuming that's what they're...
4
by: mainargv | last post by:
hi How do you rewrite codes with " ... va_list va_start va_etc", so that simple c compiler don't have to deal with them. I have written a simple c->verilog compiler but it can't deal with...
2
by: Brian Bozarth | last post by:
This is weird, I'm pretty familiar with SQL Injection - but we're getting these weird injection that is writing in the default document or home page. What it's doing is putting in script code at...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
0
by: lllomh | last post by:
How does React native implement an English player?
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.