Click here to Skip to main content
15,890,185 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I need to very quickly get a demo out of a small, simple mobile app. I have decided to use PhoneGap to package it and make it fit, and plain old HTML 5 and Angular to make it work.

That scenario is all very well if the app is static, with a local data store, if needed, on the device, but I need full and proper client-server. My initial thoughts are to initially develop the app as an ASP.NET MVC 5 app, with nice controllers and a proper database, and use JSON to communicate with the app. In MVC, the HTML comes from the view engine, but when ready for wrapping up with PhoneGap, I will capture the HTML from all controller actions and use that for the PhoneGap HTML source.

Am I barking up the totally wrong tree, or is this a feasible method, and has anyone else tried anything like this?
Posted

Just build a mobile-friendly MVC site that people can use on their mobile. If you really want an "app" you can use phonegap to make an app that uses static html\javascript that communicates with the services provided by your mobile-friendly site. So you'll end up with one back-end site that services both your MVC website front end and also the PhoneGap app.
 
Share this answer
 
Ah, this is when you come to need a Web API and a client! Since most of your content in the post is mobile-app oriented. This means you want to use the data from your website in the mobile as a native application rather than HTML content being loaded using the old default browser. I think I got you right, on your point.

Anyways, ASP.NET MVC 5 and MVC 6 they support Web APIs that you can consume through clients using an HttpClient. Every language or framework has it, and you can use them to send the requests to the API to get response back in JSON format. Note that I would also recommend that you use JSON format instead of XML because of its compact size. :-)

I have never built any application using PhoneGap (or any other framework that claims to build "native applications in HTML, CSS and JavaScript") but since they claim, they will provide you with all the tools that a programming language such as C# or C++ provides.

First stage would be to create an API. In ASP.NET (MVC 5 and MVC 6) you can create the API, using ApiController[^] in MVC 5 for Web API 2 and in MVC 6 (ASP.NET 5[^]) you can use a Controller for API and use the routes to configure where user can call it from, such as [Route("/api/[controller]")]. The rest is just the action methods that you use.

I have an article written for ASP.NET 5's Web API, if you are interested: Consuming ASP.NET 5 Web API with CRUD functions in Windows 10 native application[^]

As for the client-side, you can surely built applications in PhoneGap and then use Google to get the results for HttpClient and other stuff in that framework. One of the community thread about this discussion is: http://community.phonegap.com/nitobi/topics/can_you_do_http_requests_with_phonegap[^] which claims that HTTP requests can be sent using the XmlHttpRequest[^] object of JavaScript. That was pretty much expected. :sigh:

You can then use the data returned from the API to be used in AngularJs for rendering purposes. So, that is how you are going to make up this project! :-)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900