Skip to content

Commit

Permalink
Updated samples to use new cors middleware.
Browse files Browse the repository at this point in the history
  • Loading branch information
davidfowl committed Jul 16, 2013
1 parent 846b94d commit db05f8b
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@
<ItemGroup>
<Reference Include="Microsoft.Owin, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\Microsoft.Owin.2.0.0-rc1-20710-448\lib\net45\Microsoft.Owin.dll</HintPath>
<HintPath>..\..\packages\Microsoft.Owin.2.0.0-rc1-20715-463\lib\net45\Microsoft.Owin.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Owin.Cors">
<HintPath>..\..\packages\Microsoft.Owin.Cors.2.0.0-rc1-20715-463\lib\net45\Microsoft.Owin.Cors.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Owin.Host.HttpListener, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
Expand All @@ -61,6 +64,9 @@
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Web.Cors">
<HintPath>..\..\packages\Microsoft.AspNet.Cors.5.0.0-rc1-130715\lib\net45\System.Web.Cors.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="..\Microsoft.AspNet.SignalR.Samples\Raw\RawConnection.cs">
Expand Down
13 changes: 13 additions & 0 deletions samples/Microsoft.AspNet.SelfHost.Samples/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using System.Diagnostics;
using System.Web.Cors;
using Microsoft.AspNet.SignalR;
using Microsoft.AspNet.SignalR.Samples;
using Microsoft.AspNet.SignalR.Tracing;
using Microsoft.Owin.Cors;
using Owin;

namespace Microsoft.AspNet.SelfHost.Samples
Expand All @@ -12,6 +14,17 @@ public void Configuration(IAppBuilder app)
{
app.Map("/raw-connection", subApp =>
{
subApp.UseCors(new CorsOptions
{
CorsPolicy = new CorsPolicy
{
AllowAnyHeader = true,
AllowAnyMethod = true,
AllowAnyOrigin = true,
SupportsCredentials = true
}
});

subApp.UseConnection<RawConnection>();
});

Expand Down
4 changes: 3 additions & 1 deletion samples/Microsoft.AspNet.SelfHost.Samples/packages.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Owin" version="2.0.0-rc1-20710-448" targetFramework="net45" />
<package id="Microsoft.AspNet.Cors" version="5.0.0-rc1-130715" targetFramework="net45" />
<package id="Microsoft.Owin" version="2.0.0-rc1-20715-463" targetFramework="net45" />
<package id="Microsoft.Owin.Cors" version="2.0.0-rc1-20715-463" targetFramework="net45" />
<package id="Microsoft.Owin.Host.HttpListener" version="2.0.0-rc1-20710-448" targetFramework="net45" />
<package id="Microsoft.Owin.Hosting" version="2.0.0-rc1-20710-448" targetFramework="net45" />
<package id="Newtonsoft.Json" version="5.0.6" targetFramework="net45" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
using System.IO;
using System.Threading.Tasks;
using System.Web;
using System.Web.Cors;
using System.Web.Routing;
using Microsoft.AspNet.SignalR.Infrastructure;
using Microsoft.AspNet.SignalR.StressServer.Connections;
using Microsoft.AspNet.SignalR.Tests.Common;
using Microsoft.AspNet.SignalR.Tests.Common.Connections;
using Microsoft.AspNet.SignalR.Tests.Common.Handlers;
using Microsoft.Owin;
using Microsoft.Owin.Cors;
using Owin;

[assembly: PreApplicationStartMethod(typeof(Initializer), "Start")]
Expand Down Expand Up @@ -98,14 +100,48 @@ public static void ConfigureRoutes(IAppBuilder app, IDependencyResolver resolver
Resolver = resolver
};

<<<<<<< HEAD
app.MapConnection<MySendingConnection>("/multisend", crossDomainConfig);
app.MapConnection<AutoEncodedJsonConnection>("/autoencodedjson", crossDomainConfig);
app.MapConnection<RedirectionConnection>("/redirectionConnection", crossDomainConfig);
=======
app.Map("/multisend", subApp =>
{
app.UseCors(new CorsOptions
{
CorsPolicy = new CorsPolicy
{
AllowAnyHeader = true,
AllowAnyMethod = true,
AllowAnyOrigin = true,
SupportsCredentials = true
}
});

subApp.UseConnection<MySendingConnection>(config);
});
>>>>>>> Updated samples to use new cors middleware.

var config = new ConnectionConfiguration
{
<<<<<<< HEAD
Resolver = resolver
};
=======
app.UseCors(new CorsOptions
{
CorsPolicy = new CorsPolicy
{
AllowAnyHeader = true,
AllowAnyMethod = true,
AllowAnyOrigin = true,
SupportsCredentials = true
}
});

subApp.UseConnection<AutoEncodedJsonConnection>(config);
});
>>>>>>> Updated samples to use new cors middleware.

app.MapConnection<MyBadConnection>("/ErrorsAreFun", config);
app.MapConnection<MyGroupEchoConnection>("/group-echo", config);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@
<ItemGroup>
<Reference Include="Microsoft.Owin, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\Microsoft.Owin.2.0.0-rc1-20710-448\lib\net45\Microsoft.Owin.dll</HintPath>
<HintPath>..\..\packages\Microsoft.Owin.2.0.0-rc1-20715-463\lib\net45\Microsoft.Owin.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Owin.Cors">
<HintPath>..\..\packages\Microsoft.Owin.Cors.2.0.0-rc1-20715-463\lib\net45\Microsoft.Owin.Cors.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Owin.Hosting, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
Expand Down Expand Up @@ -70,6 +73,9 @@
<Reference Include="System.Core" />
<Reference Include="System.Management" />
<Reference Include="System.Web.ApplicationServices" />
<Reference Include="System.Web.Cors">
<HintPath>..\..\packages\Microsoft.AspNet.Cors.5.0.0-rc1-130715\lib\net45\System.Web.Cors.dll</HintPath>
</Reference>
<Reference Include="System.Web.DynamicData" />
<Reference Include="System.Web.Entity" />
<Reference Include="System.Web.Extensions" />
Expand Down
4 changes: 3 additions & 1 deletion tests/Microsoft.AspNet.SignalR.Tests.Common/packages.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Owin" version="2.0.0-rc1-20710-448" targetFramework="net45" />
<package id="Microsoft.AspNet.Cors" version="5.0.0-rc1-130715" targetFramework="net45" />
<package id="Microsoft.Owin" version="2.0.0-rc1-20715-463" targetFramework="net45" />
<package id="Microsoft.Owin.Cors" version="2.0.0-rc1-20715-463" targetFramework="net45" />
<package id="Microsoft.Owin.Hosting" version="2.0.0-rc1-20710-448" targetFramework="net45" />
<package id="Microsoft.Owin.Security.Basic" version="0.24.0-pre-20628-427" targetFramework="net45" />
<package id="Newtonsoft.Json" version="5.0.6" targetFramework="net45" />
Expand Down

0 comments on commit db05f8b

Please sign in to comment.