ASP.NET MVC REST API implementation issues

Virgil Carroll asked on March 24, 2014 15:18

I am working on a project for a client which required me writing my own ASP.NET MVC 4 Rest API. I have implemented it successfully as a stand alone web app and under another web app, but I cannot seem to get it to run under the Kentico Web Project. I keep getting a 404 not found error, even though I am following the correct path.

Any ideas on how I might be able to better troubleshoot this or why this will not work? The code was built in .NET MVC 4.0

Recent Answers


Juraj Ondrus answered on March 25, 2014 02:22

Hi,

From your description is not clear how have you added it to Kentico. Could you please provide us with more details? Have you followed the documentation on MVC?

Best regards,
Juraj Ondrus

0 votesVote for this answer Mark as a Correct answer

Virgil Carroll answered on March 25, 2014 08:55

So I am implementing this as a Restful service. I am enabling this through setting a Default Route along this path 'api/{controller}/{action}/{id}'. Calling something along this path such as api/item/getitemsbymonth/2014-03-1 should return a JSON data set of items I am processing from a datasource on the back end. So I am not implementing a page in Kentico (such as your example) but instead I am implementing a route to get the JSON callback. Does this make sense? Do I need to do this as a page in Kentico to get it to work? Or at least set the path somewhere?

I can send you my code files through support if you want, but as I said before it works fine under another web app that is not Kentico.

0 votesVote for this answer Mark as a Correct answer

Virgil Carroll answered on March 25, 2014 09:00

OR after reading the documentation, can I switch my Controller to the CMS.Controller.Global namespace to make it work?

0 votesVote for this answer Mark as a Correct answer

Virgil Carroll answered on March 25, 2014 14:51

Update: I was able to implement the Kentico MVC methodology, but the page in the site is rendering as a page, what I need is it to render as a JSON dataset which the system should return. Basically I need the page in the site to not act as a page, but instead to act as an MVC Rest Service.

0 votesVote for this answer Mark as a Correct answer

Spencer Hopkinson answered on July 9, 2014 11:39

Hi Virgil,

I have implemented web api modules succesfully into Kentico. Have you created your routing config and invoked on app start up correctly?

That's all I had to do..and allow the PUT verb on other environments!

However I do randomly see 404 responses after a while. The services will be working correctly then suddenly stop.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.