1

We have a custom search box and button that redirects the user to the search page and appends the search query however we noticed that if the query has an ampersand (&) in it the user is redirected to the generic error page. e.g

search url

http://xxxxxx/search-results?k=test & stuff

redirects to

http://xxxxxx/Pages/PageNotFoundError.aspx?requestUrl=http://xxxxx/search-results

We have tried encoding the querystring but it makes no difference. Can anyone cast some light on what can be done in this scenrio

  • This doesn't behave like that out of the box so I'd point the finger at your redirect logic. Look closely at the requestUrl param. Does it point to a valid url? – Derek Gusoff Nov 16 '17 at 14:28
  • @DerekGusoff The url is correct and without the & it works as expected. Everyone is stumped – Richard Banks Nov 16 '17 at 14:42
0

Handling an ampersand in a search query is just a matter of encoding the querystring. So for your sample of test & stuff the querystring should be ?k=test%20%26%20stuff

If you continue to get a page not found error when using that encoding then likely the search page url is incorrect.

  • unfortunately this doesnt work. It redirects even when encoded. – Richard Banks Nov 16 '17 at 14:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.