Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8025381
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T23:08:51+00:00 2026-06-04T23:08:51+00:00

We’ve got an ASP.NET MVC project which has a REST API being consumed by

  • 0

We’ve got an ASP.NET MVC project which has a REST API being consumed by a web front-end using Backbone. One of the pieces of functionality is a free text search, which currently uses a URL like this:

http://server/Search/{search-query}/{page-number}/{page-count}

This points to a Search Controller like this (with a route mapped accordingly):

public JsonResult Search(string query, int page, int pageSize)
{
    // Do search
}

It works fine for simple queries with single words or nothing with complicated characters (eg test, hello+world), but it seems like some special characters like *, &, etc break this fairly easily, and result in the following error:

A potentially dangerous Request.Path value was detected from the client

As the search query is user-entered via a text box, this needs to be more resilient to dealing with search queries that contain invalid characters.

I’ve tried encoding the search string using encodeURIComponent, but it doesn’t seem to encoding all of the problematic characters.

Is there a recommended method of allowing free text search via a REST API? Any thoughts or advice would be appreciated. Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T23:08:52+00:00Added an answer on June 4, 2026 at 11:08 pm

    I think its better to put the paging parameters in the query string too, rather than in the resource path. After all they are search dependent and not subresources of the resource you are searching in. Also there is this “/Search/Search/”, which seems a bit redundant.

    So I think your search URL should be:

    http://server/Search/?q=hello+world&page=1&page_size=10
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I want to count how many characters a certain string has in PHP, but
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
In my XML file chapters tag has more chapter tag.i need to display chapters

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.