I want to create a RESTful API for my blog application but I can’t tell how to map controllers like this.
How can it be done? Should Post be hardcoded in the URL pattern?
I want to create a RESTful API for my blog application but I can’t
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
You could map a route like this:
There’s nothing wrong with hardcoding URLs unless everything you add needs hardcoded URLs and they become unmaintainable.
What I understand is you want CommentsController called by only this route. You do not want it to be called by the default route. You can use
IgnoreRoutefor that.This will make sure CommentsController doesn’t get called without the route we defined before. I hope that was what you were trying to do.