Rest – Asp.net MVC web application and iOS mobile app

asp.net-mvcmobilerestweb-apiweb-applications

I am currently writing a web application in ASP.NET MVC, so far it is mostly a simple CRUD web app. The database is hosted on the cloud and I am using Entity Framework to interact with it.

I know that further in the development cycle we will have to make a mobile application (iOS with swift) which will interact with the same database, so I want to have a good framework that will be able to handle both without too much duplication of code or DAL, while still being secure.

Those are the options I have so far:

  • Write my MVC web application and further down the line, make http requests to my controllers action from my app. Possible problems: Security and authentications of those calls?
  • Write my MVC web application and a MVC Web API. Both my controllers of my web app and the iOS app will interact with this API. Possible problems: Will this setup work with the asp.net MVC web app?
  • Write additional web methods in my MVC controllers specifically for the REST api call of my iOS app. Possible problems: Is it possible at all?

Best Answer

The best way for iOS to communicate with your database is with REST (or JSON). So your third option is the best. Your .NET web application can easily also include web service commands that allow the JSON iOS app Set and Get the data.