locked
Help: Layered Application w/ MVC, Mobile Apps, and a Service Layer RRS feed

  • Question

  • Help: Layered Application w/ MVC, Mobile Apps, and a Service Layer

    Hello.

    I am trying to understand and develop a design for a layered intranet application (similar to what’s described in the Microsoft  Application Architecture guide at http://apparchguide.codeplex.com/).  I’m still researching the issues and technologies but have a few questions.

    The application will have an ASP.NET MVC project for the presentation layer.  It will be an intranet-based application, using Windows Authentication.  Additionally, we would like to add native iPhone/iPad and Android applications and a mobile device browser application, all of which will be “other” presentation layer projects.  That is, the MVC application will be the main presentation layer application for users on desktop or laptop computers.  The native iPhone/iPad and Android applications and the mobile browser-based application will be other ways to access the same business/domain layer and database functionality.

    To do this, I was thinking that adding a service layer as a façade into the business/domain would be the way to go.

    Is my initial thoughts about having a service layer correct?

    Is it possible for a MVC web application and native iPhone/iPad/Android applications to all access the same service layer?

    Can native iPhone/iPad/Android applications “talk to” a service layer written in C#?

    Can native iPhone/iPad/Android applications access the back-end using Windows Authentication?

    (Apologies on the native iPhone/iPad/Android application questions, I don’t know much how they work or are developed.)

    Would the service layer be a WCF project?

    Is it possible to detect that the request is coming from a mobile web browser and respond with “pages” adequate for a mobile web browser?  If so, where and how would we do this?


    Thanks in advance for answering all these questions!

    Tuesday, March 6, 2012 9:03 PM

All replies

  • Would the service layer be a WCF project? Can native iPhone/iPad/Android applications “talk to” a service layer written in C#?
    => Most of mobile apps, including those running on windows phone / surface, support only basicHttpBinding and NOT wsHttpBinding. So you don't get security out of the box. You need to implement security yourself using probably http headers for sending authentication information in custom encrypted format with every call to service layer.

    Is it possible to detect that the request is coming from a mobile web browser and respond with “pages” adequate for a mobile web browser?  If so, where and how would we do this?

    => ASP.NET MVC 4 supports this out of the box. You need to have 4 sets of .cshtml file (view) for each "page":

    1. one .cshtml file for desktop / laptop view

    2. one .cshtml file for android view   {try returning JsonResult from the action methods}

    3. one .cshtml file for iphone view      {try returning JsonResult from the action methods}

    4. one .cshtml file for windows phone view   {try returning JsonResult from the action methods}

    Best reference: ASP.NET MVC 4 Succinctly from Syncfusion

    For native apps, reuse the Html5 from MVC 4 view + CSS3 + jQuery Mobile / jqTouch and use Adobe Phonegap to give a native wrapper so that you can use geolocation, double tapping, accelerometer and other native features. Actually it would be a hybrid app.

    Is my initial thoughts about having a service layer correct?
    => Yes, you must have a service layer written in WCF 4.0 (using basicHttpBinding only). Phone, tablet, pc, .net, java, cobol etc anyone and anything can call service written using basicHttpBinding. Only thing is you need to take care of security by writing code at both client side and server side.


    Please mark as answer if this helps you. Thanks and warm regards Ambar Ray Solution Architect - Microsoft Technologies

    Friday, September 27, 2013 3:10 PM
  • Personally I'd use MVC Web Api and you'll get both worlds in one. Non .net libraries much prefer to avoid WCF/Soap (well, actually who doesn't) and you'll get far more joy/support for a REST (or at least simple) web api. Equally you can still have all the good mobile html as described by Ambar Ray

    http://pauliom.wordpress.com

    Sunday, November 3, 2013 5:35 PM