473,387 Members | 1,464 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 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 1769
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...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

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.