I am trying to search the web API url as follows:
http://localhost:8000/api/trips/World Trip/stops
In this case, the word "World Trip" is the word. But when the call arrives at the server, it arrives as follows:

" World%20Trip" with code %20to replace empty space!
Is there any tweak that needs to be made to prevent code from replacing space? I remember <httpRuntime relaxedUrlToFileSystemMapping="true" />in previous versions.
I do not want to use any method for conversion inside the server: for example HttpServerUtility.UrlEncode().
My details Route summary:
[Route("api/trips/{tripName}/stops")]
My StopController.cs
using AutoMapper;
using Microsoft.AspNet.Mvc;
using Microsoft.Framework.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using TheWorld.Models;
using TheWorld.ViewModels;
namespace TheWorld.Controllers.Api
{
[Route("api/trips/{tripName}/stops")]
public class StopController : Controller
{
private ILogger<StopController> _logger;
private IWorldRepository _repository;
public StopController(IWorldRepository repository, ILogger<StopController> logger)
{
_repository = repository;
_logger = logger;
}
[HttpGet("")]
public JsonResult Get(string tripName)
{
try
{
var results = _repository.GetTripByName(tripName);
if (results == null)
{
return Json(null);
}
return Json(Mapper.Map<IEnumerable<StopViewModel>>(results.Stops.OrderBy(s => s.Order)));
}
catch (Exception ex)
{
_logger.LogError($"Failed to get stops for trip {tripName}", ex);
Response.StatusCode = (int)HttpStatusCode.BadRequest;
return Json("Error occurred finding trip name");
}
}
}
}
source
share