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

  • SEARCH
  • Home
  • 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 8846881
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:06:13+00:00 2026-06-14T12:06:13+00:00

With the default web api route config.Routes.MapHttpRoute( name: API Default, routeTemplate: api/{controller}/{id}, defaults: new

  • 0

With the default web api route

config.Routes.MapHttpRoute(
            name: "API Default",
            routeTemplate: "api/{controller}/{id}",
            defaults: new
                      {
                          id = RouteParameter.Optional
                      }
            );

and a controller

public class TestController : ApiController
{
    [HttpGet]
    public HttpResponseMessage Get(string id)
    {
        return Request.CreateResponse(HttpStatusCode.OK, id);
    }
}

A request to 'api/test/1'

returns 1

If for some reason you send a request to 'api/test/1%20'

the route 404’s.

Now this example may seem silly since browsers trim trailing spaces, but

for a route like 'api/{controller}/{id}/{extrastuff}'

the space in '1 ' would convert to '1%20' and the request will 404 on the route not being found.

  • 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-14T12:06:14+00:00Added an answer on June 14, 2026 at 12:06 pm

    Your issue has nothing to do with WebAPI itself but how Asp.Net handles some specific urls.
    And Asp.Net handles these urls in a very paranoid way, so you need to tell it to relax.

    Add this line to your web.config under system.web:

    <httpRuntime relaxedUrlToFileSystemMapping="true" />
    

    You can read more about this topic:

    • Putting the Con (COM1, LPT1, NUL, etc.) Back in your URLs

    Also on SO:

    • "The resource cannot be found." error when there is a "dot" at the end of the url
    • Problem with a URL that ends with %20 (it describes a different context so I don’t think that this is a real duplicate)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I defined a route for the Web Api as follows routes.MapHttpRoute( name: SearchApi, routeTemplate:
I'm trying to get the new ASP.NET Web API beta (VS 2010 default Web
Is there a common method/api to list all web browsers (name, executable, default yes/no)
I'm using this to get the path and executable of default web browser: public
I am using the function below to open the user's default web browser. Public
In the following master.cs code: public partial class Default : System.Web.UI.MasterPage { protected void
I have one test wcf service with default methods and web config is :
I am starting to use MVC4 Web API project, I have controller with multiple
In an ASP.NET Web API I have modified the default GET action to accept
Consider an ASP.NET Web API service that redirects public class ThisController : ApiController {

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.