DotNetKick.com is an open-source project. Please report any bugs and let us know your great suggestions. Currently running svn revision 637 (rss)

Kick Spy!, Kick Zeitgeist and Kick Widgets

25
kicks
published 1 year, 10 months ago, submitted by Jemm Jemm 1 year, 10 months ago

weblogs.asp.net — People often ask me for guidance on how they can dynamically "re-write" URLs and/or have the ability to publish cleaner URL end-points within their ASP.NET web applications. This blog post summarizes a few approaches you can take to cleanly map or rewrite URLs with ASP.NET, and have the option to structure the URLs of your application however you want.

Add a comment 3 comments | category: | Views: 128 | Get KickIt image code
tags: , , , , | tag it

new Add a live kick counter to your blog >> liveImage

You can even customize the image by choosing your own colors, and then clicking the button below to update the preview and the html code:

  • "Kick It" text
  • "Kick It" background
  • kick count text
  • kick count background
  • border

Simply copy and paste this HTML into your blog post.


Users who kicked this story:

Comments:
Hi,

I've applied URL rewriting and appear to have lost my relative addressing, as per previous post -I've used " ~/" to acess things from root .

However a rewritten URL from :

www.2d4.com/product.aspx?department=3&product=12 to

www.2d4.com/cloths-C3/blue-product.html

The "rewriting" correctly points to the product page, however it appears to be including or "cloths-C3" as the root directory.

This effectively upsets my refences to ~/images and css and other goodies as the root is now incorrectly appending the translated directory.

I had unchecked the "must exist" box in IIS5 and I"d very much appreciate it if anyone could suggest what my error is.

Thanks very much
Bryan
posted by bryans 1 year, 1 month ago
When testing my url rewriting rules I use a simple redirection like;

<rewrite url="~/.*-P([0-9]+).html$" to="~/Product.aspx?ProductID=$1" procesing="stop" />

This results in the correct page rewrite delivering as expected e.g.

http://localhost/2Die5/Beautiful-Cami-P19.html showing as the address but the actual page rendered is the original URL,
http://localhost/2Die5/Product.aspx?ProductID=19 being executed with predictable results.

All the page behaviours including "root" relative address provided anticipated results, e.g.
NavigateUrl="~/Registry.aspx" results in a redirection to http://localhost/2Die5/Registry.aspx which is perfect.

The next step is where I am struggling, for example

When using the following redirection;

<rewrite url="~/.*-C([0-9]+)/.*-P([0-9]+).html$"
to="~/Product.aspx?CategoryID=$1&amp;ProductID=$2" procesing="stop" />


http://localhost/2Die5/Bustiers-C1/Beautiful-Cami-P19.html provides the anticipated Prodiuct.aspx page however the root directory appears as having changed.

The use of NavigateUrl="~/Registry.aspx" results in a 404 with the following error message;

Requested URL: /2Die5/Bustiers-C1/Registry.aspx

which suggest that application of rewrite rule has effectviely appended the "Bustier-C1" onto the original root directory. This is a pervasive issue with other controls and css addressing experiencing the same issue.

I'd greatly appreciate some assistance in resolving this issue.
posted by bryans 1 year, 1 month ago
I'm using "Approach 2: Using an HttpModule to Perform URL Rewriting"
i'm confusing how to handle 404 pages,

http://urlrewriter.net/index.php/support/reference/error-handler/error-page

<error-handler code="500" url="/oops.aspx" />
<error-handler code="404" url="/not-found.html" />

for these codes above, where can i put in web.config page?
One more question, i do not have permission to access to IIS configuaration, so some url like
http://www.test.com/hi
or http://www.test.com/hi.htm
or http://www.test.com/hi.asp
will be redirect to 404 pages.
how can i set up a rule for it?

thnks
Ryan
posted by goldenstate 4 months, 16 days ago



information Login or create an account to comment on this story
 

Sponsored Link: www.carlist.ie

Search:

Ads by The Lounge