URL relativa con enrutamiento de URL sin extensión

I new to URL routing, but I'm planning out how it will work so I can have a URL like products.aspx?category=cars aparece como products/cars.

Biggest problem I can see happening is that if have a link to products.aspx?category=food on a page with a rerouted URL wouldn't the browser send the user to products/cars/products.aspx?category=food?

Am I wrong or is there a way to get around this?

preguntado el 01 de febrero de 12 a las 14:02

What do you mean when you say ajax call? Surely an ajax call would be to a .asmx/.svc? Are you asking how to resolve hrefs correctly on your products/cars page? -

@Jon no. I rephrased the question to make it more generic -

Here's a how-to with URL rewrite: learn.iis.net/page.aspx/461/… -

3 Respuestas

It will send it to products/cars/products.aspx?category=food, correct.

You can solve this by adding a preceeding '/' to your url so it becomes /products.aspx?category=food

However if you're URL mapping won't you want to build your links as "products/food" so that they can be rewritten?

Respondido 01 Feb 12, 19:02

What you are after is URL Rewriting or Friendly URLS. Heres a link that might help for ASP.NET I do not use NET myself so not sure

http://www.codeproject.com/Articles/18318/URL-Mapping-URL-Rewriting-Search-Engine-Friendly-U

Pero esto podría ayudar: http://en.wikipedia.org/wiki/Rewrite_engine

Respondido 01 Feb 12, 18:02

Typically, with URL rewriting, you are always going to be using index.aspx. All of your paths will be setup with a pattern you establish.

index.aspx?display=products&category=food

se convertiría en

mysite.com/products/food or mysite.com/products/category/food

You are able to customize how you handle this with configuration options with your particular rewriting tool.

Respondido 01 Feb 12, 18:02

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.