Reputation: 1009
We're trying to create our first web api using the .net framework. To try this we've used this demo project: http://www.codeproject.com/Articles/549152/Introduction-to-ASP-NET-Web-API
In this project we've changed the find() function of the AJAX script so it only sends one var to our new democontroller.:
<script>
var uri = 'api/Demo';
function find() {
var id = encodeURIComponent($('#prodId').val());
$.getJSON(uri + '/' + id)
.done(function (data) {
$('#product').text(data);
})
.fail(function (jqXHR, textStatus, err) {
$('#product').text('Error: ' + err);
});
}
</script>
The function in this democontroller returns the exact input so we can see that it works:
public class DemoController : ApiController
{
public IEnumerable<String> Get()
{
List<string> bla = new List<string>();
bla.Add("DEMO!!!");
return bla;
}
public IHttpActionResult Get(string id)
{
return Ok(id);
//return input for test;
}
}
All the strings we send work perfectly exapt strings which contains a '.' or '%2E' this causes a error: NOT FOUND. This will still happen if we set a static answer.
What can we do to fix this? We are trying to send an email adress so we need the '.'.
Upvotes: 0
Views: 305
Reputation: 4166
Have a look at this answer MVC4 project - cannot have dot in parameter value?
Try changing the Web.Config file
<system.web>
<httpRuntime relaxedUrlToFileSystemMapping="true" />
</system.web>
Upvotes: 2