locked
Windows phone 8.1 : Building app with WebView and HttpRequest

    Question

  • Hi there,

    I've been searching for a solution to my problem and with no luck for now.

    I will try here if someone can help me out with this :s

    I'm trying to build a third party app that rely on an University website (I'm not the owner).

    Our  system work with one authentification portal (HTTPS) and once we've been log in we have acces to every ressource on our campus ( some cookie is stored, for the session, on the web browser for the time we are using the service).

    To make my project work, i've thought that the easiest way was to let the user login trought the authentification portal from a WebView control and after that is done I can use the cookie (in result of a successfull authentification) to do the rest of my work with simple HttpRequest to query all the information I need.

    But from now i've seen that the reverse scenario was possible ( do some work with HttpRequest and push cookie into a WebView control )

    I've also tried to work only with the WebView control but since i need to extract data from the HTML code on a webpage I can't do that sort of job with this control. I've tried to use ScriptNotify with no succes since some page use the HTTP protocol instead of HTTPS (wich is the new requirement since WP 8.1)

    Does someone have a clue on what I can do to make it reality ?

    Tuesday, September 30, 2014 3:04 PM

Answers

  • In past I encountered such a situation where for some educational site I had to build a Windows Store App, where site owner did not expose any services for us to consume functionality.

    I wrote some code that used HttpWebRequest to post username and password to the server and from HttWebResponse we extracted the cookie to use for further transactions. But all of this was kind of writing Coded UI Test cases in app. To extract information I used regular expressions. All of this was fine until there were no changes in Web App UI and/or it went into alternate flows.

    This type of approach is very specific to Web App you are working with, so there will not be any generic code to share with you.

    The conclusion is that this is not a good way to develop any app! This is not a recommended approach to do things. Backend system should expose some services (either Web Service or WCF) and the we should develop app around it.


    -- Vishal Kaushik --

    Please 'Mark as Answer' if my post answers your question and 'Vote as Helpful' if it helps you. Happy Coding!!!

    • Marked as answer by KimForest Thursday, October 2, 2014 2:02 AM
    Wednesday, October 1, 2014 4:44 AM

All replies

  • In past I encountered such a situation where for some educational site I had to build a Windows Store App, where site owner did not expose any services for us to consume functionality.

    I wrote some code that used HttpWebRequest to post username and password to the server and from HttWebResponse we extracted the cookie to use for further transactions. But all of this was kind of writing Coded UI Test cases in app. To extract information I used regular expressions. All of this was fine until there were no changes in Web App UI and/or it went into alternate flows.

    This type of approach is very specific to Web App you are working with, so there will not be any generic code to share with you.

    The conclusion is that this is not a good way to develop any app! This is not a recommended approach to do things. Backend system should expose some services (either Web Service or WCF) and the we should develop app around it.


    -- Vishal Kaushik --

    Please 'Mark as Answer' if my post answers your question and 'Vote as Helpful' if it helps you. Happy Coding!!!

    • Marked as answer by KimForest Thursday, October 2, 2014 2:02 AM
    Wednesday, October 1, 2014 4:44 AM
  • The WebView App template featuring the Web View control, is probably the easiest way to create an app IF you already have basic HTML, CSS and JavaScript knowledge.  In this lesson, we’ll look at the basics, in the next lesson we’ll build an app based on something from the JavaScript and JQuery Fundamentals for Absolute Beginners series just to demonstrate what’s possible and to demonstrate the types of issues you might face when converting an existing JavaScript-based app to the Web View App Template.

    http://channel9.msdn.com/Series/Windows-Phone-8-1-Development-for-Absolute-Beginners/Part-13-Working-with-the-Web-View-App-Template

    Wednesday, October 1, 2014 6:32 AM
  • I've tried in the past HTTPRequest command but  the cookie handling has a known bug, I never got it working this way and never touch the code again since 8.0.

    But when I saw your reply, I given a second chance and know what ? it's work like a charm on 8.1 !

    Thanks for all,

    regards

    Kim

    Thursday, October 2, 2014 2:08 AM