9

My team and I are currently developing an application for both Android and iOS using ASP.NET MVC 4, HTML5, and PhoneGap. The development works perfectly fine; however, one question remains unanswered: What is the recommended approach to generate the three files PhoneGap needs (one HTML page, one JavaScript file, and one CSS stylesheet) from our MVC solution?

Would you recommend using a Razor template-based approach? Or would you simply automatically copy the output HTML source after each build? Or would you suggest something completely else?

Marius Schulz
  • 15,976
  • 12
  • 63
  • 97

1 Answers1

3

This morning, we decided to let ASP.NET MVC render a single view containing all our application's HTML which references several JavaScript files and CSS stylesheets. We then automatically grab the rendered HTML source and copy an index.html into a certain export folder on our local machine. That folder is ready to be deployed because it contains only one HTML file and additional JavaScript and CSS resources – exactly what PhoneGap expects.

Marius Schulz
  • 15,976
  • 12
  • 63
  • 97
  • 1
    That should be the way to do it since you can't put the ASP.NET MVC source into the PhoneGap app obviously. You don't have any logic that needs server-side processing in the app? Why make it ASP.NET MVC with a single view to begin with? – mccrager Jun 12 '12 at 13:57
  • 1
    We have a REST service that our app will call, but that's it. The app itself renders a single HTML page in the end (and a couple of CSS and JavaScript files). However, we can make use of all features of MVC (partial views, child actions, ...) to generate that content which is why we decided to use ASP.NET MVC instead of entirely static content in the first place. – Marius Schulz Jun 12 '12 at 14:25
  • 1
    Are you using MVC really to organize your code and just and an engine to produce your single page application? We are about to start a project and I'm struggling with just creating a single HTML/Jquery Mobile file or build it in MVC. MVC for what we need to accomplish may be overkill. I'm leaning towards mccrager's post and not make it MVC. The one problem I see with a single page application is the organization and source control when we have more than a couple of Devs on a project. – pehaada Aug 03 '12 at 14:54
  • Yes, we really *did* use MVC's goodnesses to organize and manage our views and JavaScript files. Namely, these goodnesses are partial views and bundling and minification support for both JavaScript and CSS coming from Combres. – Marius Schulz Aug 04 '12 at 14:55