My WebApi file contains;
public static void Register(HttpConfiguration config)
{
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{name}",
defaults: new { name = RouteParameter.Optional }
);
}
I'm making an ajax call;
<script>
$(document).ready(function () {
$("#grid").bootgrid();
$("#grid").on("click.rs.jquery.bootgrid", function (e, columns, row) {
url = 'api/AdminContentApi/' + row.Name;
$.ajax({
url: url,
type: 'GET',
success: function (d) {
},
error: function (xhr, textStatus, errorThrown) {
alert("Error in operation");
}
});
});
});
</script>
and finally my Controller code;
[Authorize(Roles = "Admin")]
public class AdminContentApiController : ApiController
{
[HttpGet]
public IHttpActionResult GetContentDetail(string name)
{
content c = ContentRepository.GetContentByName(name);
if (c == null)
{
return NotFound();
}
return Ok(c);
}
}
}
My question and the problem is that when the call is envoked I would expect the url to be: api/AdminConTentApi/HOME_1
instead I'm getting; /AdminContent/api/AdminContentApi/HOME_L
Where/How/Why/WTF is it prefixing the url with AdminContent?
Thanks
What I have tried:
According to all the tuts I've read I am doing it correctly but have been working for hours on this problem and have tried everything that tuts described.