locked
What can I use for my server side lang? RRS feed

  • Question

  • How can I store values in a database and whatnot, using forms.

    If there is a way to do it with PHP, that is awesome, but I'm kind of guessing microsoft is going to be a little too controlling to let me have that one...

    I would certainly hope I don't have to pay for windows Azure or something though...

    Thursday, September 15, 2011 3:07 PM

Answers

  • maxhudson,

    If you have been working with PHP & MySQL in the past, then you have probably been creating websites, where you use PHP to generate HTML which is sent to the browser, and included in it is the logic to send requests back to the server to fetch more HTML based on the user's interaction with the page.

    The recommended architecture for HTML/Metro apps is a little different in that the client app tends to be written to be smarter than an old fashioned web page. Instead of making a request to the server and getting back HTML for the entire UI, it will make requests for data from the server, which is typically provided using JSON or XML, and then the client app does the conversion of the data from the request into HTML. In this case the server is still using a database as the storage for the data, but will use XML or JSON as the way of formatting the data in the HTTP requests & responses.

    If you do a search for REST and PHP, you'll find some articles that can help explain the concepts.

    http://www.bing.com/search?q=rest+php+tutorial&qs=AS&sk=RQ2&pq=rest+php&sp=3&sc=6-8&form=QBRE

    Wednesday, September 28, 2011 12:25 AM

All replies

  • A Metro style HTML5/JavaScript app can contain iframes that point to a web page on any domain running any software on the server.
    Thursday, September 15, 2011 5:46 PM
  • The ideal Metro style application is primarily written as a client side application, using the AJAX style methodology. So instead of using a server to deliver ready to render pages of html, your application should be a single page that is loaded from the app's package. That page is then used to load the logic of the application, which can dynamically create HTML for the UI.

    As such an app doesn't require a server, unless it needs to be able to get data from the server. The server can deliver content as html, which makes sense for text based content such as an article or blog post, but for data scenarios, its generally better to deliver data from the server to the app using JSON or XML format. You can then use the controls in WinJS such as ListView to then convert that data using a template into a list.

    As far as the app is then concerned, it does not matter what technology stack is used for the server, or where it is hosted. As long as the app can fetch or post the data via HTTP it can easily use it.

    Thursday, September 15, 2011 10:03 PM
  • But I need to retrieve it in sql format, not XML format.

    I really hope Microsoft wasn't dumb enough to make that impossible..

     

     

    Thursday, September 15, 2011 11:34 PM
  • Why does it *have* to be in SQL format? The intermediate layer of your application is just that, intermediate. It could be anything you wanted assuming the environment has constructs for handling it.

    It's fairly straight forward to have a web compartment for your 'web connected' content and then your client-side app logic in the local compartment. When your local compartment needs to access information in the web compartment, you can use window.postMessage to push data between the two.

    Using the approach I outlined above, you can have something like a local storage database of information which you're storing your user's info in. Then have a map widget in the web compartment and do window.postMessage from the local compartment to the web compartment with the locations to show on that map widget. In this way, you've sandboxed the "unsafe" web content from the safe client side content.

    Friday, September 16, 2011 12:31 AM
  • Why does it *have* to be in SQL format? The intermediate layer of your application is just that, intermediate. It could be anything you wanted assuming the environment has constructs for handling it.

    It's fairly straight forward to have a web compartment for your 'web connected' content and then your client-side app logic in the local compartment. When your local compartment needs to access information in the web compartment, you can use window.postMessage to push data between the two.

    Using the approach I outlined above, you can have something like a local storage database of information which you're storing your user's info in. Then have a map widget in the web compartment and do window.postMessage from the local compartment to the web compartment with the locations to show on that map widget. In this way, you've sandboxed the "unsafe" web content from the safe client side content.

    How do I use window.postMessage and if I say wanted to store user accounts in one table or whatever you think the equivalent of that will have to be, and say user posts in another storage "unit"?
    Friday, September 16, 2011 1:16 AM
  • How do I use window.postMessage and if I say wanted to store user accounts in one table or whatever you think the equivalent of that will have to be, and say user posts in another storage "unit"?

    To be clear, you want to:

    • store user accounts in table Foo
    • store user posts in table Bar

     

    Based on this description, it sounds like you'd need a RESTful backend API which you could insert information with appropriately. That is to say, sending (HTTP POST/PUT) data to:

    • http://someserver/posts/add would add a post
    • http://someserver/posts/delete would delete a post
    • http://someserver/accounts/add would add an account
    • etc...

     

    From there, you could build out to have that remote HTTP server handle whatever you needed.

     

    The key thing to get here is that you're building a client-side app if you're building a Metro JS/HTML5 application. You aren't intended to be running some webserver on the user's machine with SQL server and all of that. You're intended to offload that work to a server system that already exists if you have an existing Web service.

     

    Does that make sense? I think the big thing you seem to be thinking is that you should be writing your front end and back end all within the bounds of the new Windows 8 paradigm, but that isn't entirely the case. It seems you're shooting for an LOB (Line of Business) application in which it is appropriate to use the approach I outlined above.


    Friday, September 16, 2011 1:35 AM
  • I'm sorry, but I have no idea what that means...

     

    I have use PHP and mySQL in the past to make websites, but I don't really have any idea how to do what you are saying despite your examples..

    Friday, September 16, 2011 2:05 AM
  • So what if your client application (lets say a simple cashbook application) needs to store and work with a significant amount of local (eg SQL CE or express) data on the client machine?  Can the client JavaScript call into a class library (eg C#) deployed along with your javascript/html?

    Sorry for the dumb questions.  I'm just trying to get the "lay of the land".

    Friday, September 16, 2011 4:06 AM
  • This thread isn't about local data storage, rather remote data storage.
    Friday, September 16, 2011 4:13 AM
  • So what if your client application (lets say a simple cashbook application) needs to store and work with a significant amount of local (eg SQL CE or express) data on the client machine?  Can the client JavaScript call into a class library (eg C#) deployed along with your javascript/html?

    Sorry for the dumb questions.  I'm just trying to get the "lay of the land".

    Your options for this include:

    1. Windows.Storage.ApplicationData APIs if you have a small enough data set.
    2. Writing your own storage format in C# that the JS code would call
    3. Writing your own storage format in C++ that the JS code would call
    4. Using the Windows.Storage APIs to write local user data in some custom format of your choosing.

    HTML5 Local Storage may also be in there as well but I'm unable to find the documentation for it currently.


    Friday, September 16, 2011 3:02 PM
  • To sum up, you could do your own customer solution in localstorage and C# however, you may rethink whether or not you want to go that route since the other mentioned architecture would probably be a better way to go


    Jeff Sanders (MSFT)
    Friday, September 16, 2011 3:03 PM
    Moderator
  • Which portion? If you're unsure of how one constructs a RESTful API, Wikipedia has a pretty good page on REST. The model I'm proposing to solve this problem means having a server and many clients and using the MVC design pattern:

    • server - hosts your RESTful API which you use XmlHttpRequest (ajax) from the client to push/receive data from with PUT/POST
      - The server would handle all of the database related operations as well as a business logic for heavy data processing.
      - It would run a web server that provides the RESTful API.
      - It would run a database server of your choosing (SQL, NoSQL, what-have-you).
      - In an MVC style of thinking, you'd use the server as your Model.
    • client - a Metro-style JS/HTML5 application which many users run. 
      - This client uses XmlHttpRequest to push/receive data to and from the server above.
      - The client handles both the View and the Controller of your application. 
    This is simply an example of how to solve your problem, there are likely many other ways you can do so.
    Friday, September 16, 2011 3:16 PM
  • Ok, this sounds like it would work, but I don't see what the api is or how to use it.

     

    Saturday, September 17, 2011 5:59 AM
  • Hey Max,

    There are a couple of examples of getting data from a web server and processing then displaying the data in the sample apps.  One is the Custom-data-sources-example.  See this thread for info: http://social.msdn.microsoft.com/Forums/en-US/winappswithhtml5/thread/f6d5407b-240d-46f3-a92d-33f0a9aef82b/

    -Jeff


    Jeff Sanders (MSFT)
    Thursday, September 22, 2011 1:10 PM
    Moderator
  • I would really like to use XML if it can work.

    I need to be able manage the XML file though which is difficult because i need to be add, remove and modify data in the XML doc which won't even be possible if it's stored online right?

    Thursday, September 22, 2011 2:03 PM
  • You can use XML, you can store it online or locally.

    See the samples for the 'ApplicationData sample'  for storing locally.

    XML manipulation will be the same way you have done it in the past (XML API Scenario Sample for the Windows Runtime ).

     


    Jeff Sanders (MSFT)
    Thursday, September 22, 2011 2:11 PM
    Moderator
  • I have never used XML in the past.

    I need to be able to add, edit and remove entries as well as sort and limit results

    Saturday, September 24, 2011 2:39 AM
  • maxhudson,

    If you have been working with PHP & MySQL in the past, then you have probably been creating websites, where you use PHP to generate HTML which is sent to the browser, and included in it is the logic to send requests back to the server to fetch more HTML based on the user's interaction with the page.

    The recommended architecture for HTML/Metro apps is a little different in that the client app tends to be written to be smarter than an old fashioned web page. Instead of making a request to the server and getting back HTML for the entire UI, it will make requests for data from the server, which is typically provided using JSON or XML, and then the client app does the conversion of the data from the request into HTML. In this case the server is still using a database as the storage for the data, but will use XML or JSON as the way of formatting the data in the HTTP requests & responses.

    If you do a search for REST and PHP, you'll find some articles that can help explain the concepts.

    http://www.bing.com/search?q=rest+php+tutorial&qs=AS&sk=RQ2&pq=rest+php&sp=3&sc=6-8&form=QBRE

    Wednesday, September 28, 2011 12:25 AM