855.367.3511 | CONTACT US

Author Topic: Support - App/Server Split  (Read 2504 times)

ncar

  • Jr. Member
  • **
  • Posts: 69
    • View Profile
Support - App/Server Split
« on: July 27, 2016, 01:15:06 pm »
I have an ASP.NET MVC application using Mobilizer.
I currently have them on the same server, but would like to move Mobilizer to it's own server.
Can this be done? I don't see anything in the web.config to specify a server other than the Report Server.

taniac

  • Full Member
  • ***
  • Posts: 148
    • View Profile
Re: Support - App/Server Split
« Reply #1 on: July 27, 2016, 01:19:04 pm »
It can be done in many ways.  You can either run Mobilizer as a standalone app as you are doing.  You can run it in an app of your own using the SDK.  Both of these options has the client as server code in the same domain. 

If you want to have the client code in one app and the server code in another app you can do that to but you need to setup CORS.

This setup is more complicated and but several of our customers are doing it.  The complication is ASP.Net not mobilizer.  Mobilizer has just one setting you need to set.

Mobilizer will determine the API location from the load path of the js files.
For example <script type="text/javascript" src="http://hTTP://MyMobilizerServer/Mobilizer/Forerunner/Bundles/forerunner.min.js"></script>


If your client code is on a different domain then your need to enable CORS to make cross domain calls.

To do this for Mobilizer you need to set the following setting in your web.config that is hosting the server API.  If using mobilizer this is the mobilizer web.config
You need to tell Mobilizer it can trust a different domain.

<httpProtocol>
      <customHeaders>
        <clear />
        <add name="Access-Control-Allow-Origin" value="http://localhost:1337" />
        <add name="Access-Control-Allow-Credentials" value="true" />
        <add name="Access-Control-Allow-Methods" value="GET, POST" />
        <add name="Access-Control-Allow-Headers" value="Content-Type, *" />
       
      </customHeaders>

</httpProtocol>


If you want to pass credentials then you need to also set a header on the client before making ajax calls
For Mobilizer you simply need to set before creating any forerunner objects.

forerunner.config.enableCORSWithCredentials = true;