The easiest way is to have two WebSharper projects:

  • The server side is a Client-Server Application and contains the RPCs.

  • The mobile app itself is a Single-Page Application and is purely client-side.

    • If you have a VS Cordova project then here is how to set up your SPA to output its code into it:

      • Edit your SPA's .fsproj file to set the property WebSharperBundleOutputDir to something like ../MyCordovaProject/www/Content so that WebSharper outputs the necessary files in that folder.

      • Add the necessary script and style tags in MyCordovaProject/www/index.html (just copy them from your SPA's index.html; then you can remove that file).

    • Then, to support RPC:

      • the SPA must reference the server-side project, so that you can call the RPC functions in F#.

      • You need to tell it where the server side is located by using the following code at startup:
        WebSharper.Remoting.EndPoint <- "http://my-server-url"

By on 7/20/2016 7:59 AM ()
1
2
3
4
5
    After i added this line to server side, it is work. thank you.
    WebSharper.Web.Remoting.DisableCsrfProtection()
    WebSharper.Web.Remoting.AddAllowedOrigin("file:///") //local? or cordova
    WebSharper.Web.Remoting.AddAllowedOrigin("file://") //my this is correct
    WebSharper.Web.Remoting.AddAllowedOrigin("null") //it is necesery local
By on 7/20/2016 12:45 PM ()

I think it is about cors. How can fix it?

By on 7/20/2016 11:35 AM ()

Thank you, I do what you say. now I have one problem. SPA project make request with empty params end request head not post, it is options. Beacuse this response is 200 but empty.

By on 7/20/2016 11:14 AM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper