locked
SQL DB to WebAPI to App

    Question

  • So I have an SQL DB setup. I also have a WebAPI that can make changes to it, which I made using this: http://www.codeproject.com/Articles/43438/Connect-C-to-MySQL.  

    I know I'm supposed to have that WebAPI act as a service, but I'm not sure how to do that, I just run the script at the moment and get it to POST/DELETE etc. with a custom input at the moment.  

    I have a Windows server setup that I figure I could utilize as the hosting service for the WebAPI, but again, I don't know how to set that up.      

    Finally, once that's setup I'll need my app to use XHR to actually talk to the WebAPI in order to do the database stuff. I haven't been able to find anything useful in the Dev Center that makes me think I could use it as an example.  

    Any help/useful links would be appreciated. 

    Wednesday, May 29, 2013 6:33 PM

Answers

All replies

  • Where do you want to deploy this

    1. In cloud

    2. In network server

    Right now you can deploy on to a network (The windows server setup you have) IIS or local IIS :

    http://forums.asp.net/t/1829000.aspx/1

    or self host it :  http://www.asp.net/web-api/overview/hosting-aspnet-web-api

    To consume local web services in app use the WinJS Xhr and pass the url to get data. Check out this and this too for samples

    * Note : make sure in app manifest --> Capabilities --> Private Networks are checked to access services hosted on internal machines or network.

    - Girija


    Wednesday, May 29, 2013 6:56 PM
  • So I have a website that has 2 forms in it at the moment. If I fill the forms out and hit the submit button then my MySql database will be changed.  I've written the website in .aspx with the backend in .aspx.cs.  Is that kind of site sufficient for setting up the WinJS Xhr and passing that url in?
    Friday, June 7, 2013 3:10 PM
  • For consuming in Xhr it should be an web method enpoint.. Something you can call directly and that returns data (in XML or JSON). You cannot query views (aspc , CHSTM, html) endpoints..

    It should be a Web APi controller or a Service endpoint (REST is best).

    - Girija


    Please mark responses as answered if it helped you.. This helps others... - Girija Shankar Beuria

    Friday, June 7, 2013 9:50 PM
  • So if I use this: http://code.msdn.microsoft.com/ASP-NET-Web-API-with-afa30545#content

    This can be the middle man between my app and the database?  

    Monday, June 10, 2013 3:17 PM
  • Yes.. That would work.. You can use Xhr to consume the JSON in you app..

    - Girija


    Please mark responses as answered if it helped you.. This helps others... - Girija Shankar Beuria

    Monday, June 10, 2013 3:42 PM
  • I can use the Xhr in my app to consume the JSON in the app I linked you mean?
    Monday, June 10, 2013 6:54 PM
  • Yes.

    - Girija


    Please mark responses as answered if it helped you.. This helps others... - Girija Shankar Beuria

    Monday, June 10, 2013 8:14 PM