locked
Two web apps in WebRole problem RRS feed

  • Question

  • User-565109609 posted

    Hi,

    I have a requirement to have two web apps (one site with two different skins) to work with signalR.
    Apps are opening fine with the configuration in the ServiceDefinition.csdef where the second web app have hostHeader. SignalR is working on the main web site but i have problem setting up the signalR on the second web site.

    1. If i don't change the url property on the connection for the second web site then no errors in the browser but signalR won't work at all. Debugging it i can see that the signalR configuration is executed but the Hubs are not instanced. The main web app is working fine, and hubs are instanced fine. All the code is common for both and is extracted in a separate class library. The C# code left in both web apps are the Global.asax.cs and the Startup configuration for SignalR.
    2. If I change the url to point directly to the first web site, and after I solved the cross domain issues and configured it in the web.config, also changed the startup configuration to allow cors using owin for signalr 2, the final javascript error I got is: SignalR XMLHttpRequest cannot load...  The 'Access-Control-Allow-Origin' header contains multiple values.

    Anybody got into same problem or have an idea how to solve it?

    Thanks,
    Boban.

    Thursday, July 30, 2015 2:41 AM

Answers

  • User2057898579 posted

    Try remove 

    <customHeaders>
       <add name="Access-Control-Allow-Origin" value="*" />
       <add name="Access-Control-Allow-Headers" value="Content-Type" />
    </customHeaders>

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, July 30, 2015 5:09 AM

All replies

  • User2057898579 posted

    Hi Boban

    I remember me that I had something like that. There I had multiple configurations for the header. Are you shure that you do not have multiple settings for the  "cross domain issues" ?

    Kind Regards

    Thursday, July 30, 2015 3:57 AM
  • User-565109609 posted

    I have these settings in the main app web.config:

    <customHeaders>
       <add name="Access-Control-Allow-Origin" value="*" />
       <add name="Access-Control-Allow-Headers" value="Content-Type" />
    </customHeaders>

    I had also tried with http://www.mydomainname.com for the first setting value.

    The startup code for singlaR is:

    public void Configuration(IAppBuilder app)
    {
    #if !DEBUG
       var serviceBusConnectionString = "my service bus conection";
       GlobalHost.DependencyResolver.UseServiceBus(serviceBusConnectionString, "mysbname");
    #endif

    app.Map("/signalr", map =>
      {
        map.UseCors(CorsOptions.AllowAll);
        var hubConfiguration = new HubConfiguration
        {
        };

        map.RunSignalR(hubConfiguration);
      });
    }

    Configuration in the ServiceDefinition.csdef is:

    <Sites>
    <Site name="Web">
    <Bindings>
    <Binding name="Endpoint1" endpointName="Endpoint1" />
    </Bindings>
    </Site>
    <Site name="Web2" physicalDirectory="..\..\Sites\ubetPro.UI.Web.Tote">
    <Bindings>
    <Binding name="Endpoint1" endpointName="Endpoint1" hostHeader="www.mydomainname.com" />
    </Bindings>
    </Site>
    </Sites>

    Thursday, July 30, 2015 5:02 AM
  • User2057898579 posted

    Try remove 

    <customHeaders>
       <add name="Access-Control-Allow-Origin" value="*" />
       <add name="Access-Control-Allow-Headers" value="Content-Type" />
    </customHeaders>

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, July 30, 2015 5:09 AM
  • User-565109609 posted

    Thanks, that was it.
    I was fighting with cross domain issue first, and then changed the configuration on the signalr start with the cors specifics.

    Thursday, July 30, 2015 6:11 AM