Mobile and web layers RRS feed

  • Question

  • User1622294484 posted

    Hey guys,

    So I have a 3 layer application , for the presentation layer it's a web .What I want to do is create a web service so when the user is connected from a pc the web app is opened and if he's connected from mobile it's the mobile layer that is opened . Any idea how to do so ?

    Thursday, May 8, 2014 3:27 AM

All replies

  • User-902516579 posted


    Have you looked at this:  http://www.asp.net/whitepapers/add-mobile-pages-to-your-aspnet-web-forms-mvc-application


    HTH, Benjamin

    Thursday, May 8, 2014 8:26 AM
  • User1622294484 posted

    oh okay that seems to be a very good link but I hoped to find one that is consumed by a webservice 

    Thursday, May 8, 2014 8:46 AM
  • User-417640953 posted

    oh okay that seems to be a very good link but I hoped to find one that is consumed by a webservice 

    Hi kryptong,

    Thank you post the issue to our forum.

    For your issue, I think you can judgement the request comes from mobile or browser.

    Then rewrite the request path to the corresponding Application layer like below.

            public string ServiceMethod()
                if (HttpContext.Current.Request.Browser.IsMobileDevice)
                    //go to the web application layer
                else {
                    //go to the mobile application layer
                return "Hello World";

    Hope that helps, thanks.

    Best Regards!

    Friday, May 9, 2014 2:29 AM
  • User1622294484 posted

    hi Fuxiang,

    so I tried to create a webservice with the code that you give me but when executing , whether it is from browser or mobile , I'm redirected to my web pages.Wich is normal I think because even if I created a webservice I didn't tell him that on my session  start do what the web service tells you to do ? so how can I do that ?

    Friday, May 9, 2014 3:03 AM
  • User1565039490 posted

    If I were you I would opt to SOA (Service Oriented Architecture) for your project. Just expose WCF service as a very thin layer on top of a separate business layer. In other words the WCF layer should do nothing more than just make calls to the business logic layer. http://stackoverflow.com/questions/8388679/wcf-service-and-business-logic

    public User GetUser(int id)
         return _userLogic.GetUser(id);

    Friday, May 16, 2014 6:27 AM