views:

77

answers:

1

I asked a previous question on how to optimize my search for SEO and users without JavaScript, and I figured out my answer by using RedirectToAction

However, in doing so, I've found a new issue that I need to resolve.

If I submit a search

"the quick brown fox jumped over the lazy dogs"

(trying to mimic Google with the "quotes" for complete phrases)

The application blows up on me (YSOD)

Illegal characters in path.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

The url looks like this (Firefox)
http://localhost/search/"the quick brown fox jumped over the lazy dogs"

I tried using Url.Encode but that didn't work either... the url looks like
http://localhost/search/%2522the%2bquick%2bbrown%2bfox%2bjumped%2bover%2bthe%2blazy%2bdogs%2522

and the error says

Server Error in '/' Application.
HTTP Error 400 - Bad Request.

It must be something very obvious that I'm missing. Exception Details: System.ArgumentException: Illegal characters in path.

A: 

Looking at the form in your previous question I would have expected searchTerm to be a query string parameter and not part of the route.

http://localhost/search?searchTerms=..

If you want search to be part the routes, you will have to setup the routing correctly to.

If you provide more of the stack trace or your routing configuration you may get a better answer. Hope this helps anyway.

tarn
There was no stack trace. What I posted as the "400" error was all there was.
rockinthesixstring
Did you try changing searchTerms from part of the route into a query string?
tarn
yes it works just fine as part of the querystring. I was just hoping i could use it as part of the route - similar to "The Pirate Bay" - http://thepiratebay.org/search/searchTerm
rockinthesixstring
Fair enough. It appears there are issues in ASP.NET regarding some special characters in routes, this can be worked round with a custom route (and has maybe been fixed in 3.0?). This question might help: http://stackoverflow.com/questions/373599/how-to-pass-special-characters-so-asp-net-mvc-can-handle-correctly-query-string-d
tarn
Thanks for that... I'll keep an eye out.
rockinthesixstring