0

I am new to asp.net mvc world. So I have a question

I have already developed a web app using Asp.net MVC (also deployed on production).

Currently I am working on mobile apps. For this I need web services (restful).

For Restful web services do I have to make a new project (within existing solution) or can I incorporate Restful webservices into my existing (Asp.net MVC) project ? (I prefer 2nd option if possible)

If I have to make new project for Web Api, then how will I deploy both projects on production knowing that Web Api project is dependent on Asp.net-MVC project ?

4
  • if your mvc project has end points which return desired result for you mobile apps you are good to go Commented Jun 21, 2017 at 6:16
  • @Krishna how would I know if mvc project has any end point? My web-app is quite basic. Commented Jun 21, 2017 at 6:18
  • End point is nothing but a action method which returns desired result for your app Commented Jun 21, 2017 at 6:20
  • I do have controllers and methods which returns ActionResult and have annotations [HttpGet] and [HttpPost] on top of methods. Is this what you are talking about ? If yes then can you share a link how to use these action methods as restful webservice ? Commented Jun 21, 2017 at 6:25

1 Answer 1

1

One thing you need to understand first is whether it's a web service,wcf service or a Web API the only thing you need is to get a json/xml output which you can use in your mobile app.

Let say you have and asp.net mvc application which has some action methods, but you might be returning a View or PartialView which is not you want for a mobile app to parse. So you need to create an action method which returns JsonResult.

If you want to use all the RESTFul verbs like POST,PUT,GET,DELETE you can add another controller which inherits from APIController and write methods there, but either ways output is same.

So it's up to you what to do and how to proceed, only thing is with an APIController you will have some more verbs and code ahve some special returns like "Ok" e.t.c

Sign up to request clarification or add additional context in comments.

2 Comments

ActionMethods are also web services ?
no you can use them just like a web api service, lets say you you have an action method which returns json result, you can just call it as www.domain.com/controller/action which will give you your desired result

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.