Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
228 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,7 @@ | ||
packages | ||
/packages | ||
node_modules | ||
bin | ||
obj | ||
*.suo | ||
*.csproj.user | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,12 @@ | ||
connect-owin Samples Repository | ||
=============================== | ||
|
||
# ASP.NET WebApi Sample | ||
|
||
$ cd Samples.WebApi | ||
$ msbuild Samples.WebApi.csproj | ||
$ npm install | ||
$ node server.js | ||
|
||
Open http://localhost:3000/Api/Hello/World | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 2012 | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{E526A334-884E-43C0-8293-0829C9EB80AC}" | ||
ProjectSection(SolutionItems) = preProject | ||
.nuget\NuGet.Config = .nuget\NuGet.Config | ||
.nuget\NuGet.exe = .nuget\NuGet.exe | ||
.nuget\NuGet.targets = .nuget\NuGet.targets | ||
EndProjectSection | ||
EndProject | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".node", ".node", "{DCCEC959-C45D-436F-AB69-0204FF8D83FD}" | ||
ProjectSection(SolutionItems) = preProject | ||
Samples.WebApi\package.json = Samples.WebApi\package.json | ||
Samples.WebApi\server.js = Samples.WebApi\server.js | ||
EndProjectSection | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Samples.WebApi", "Samples.WebApi\Samples.WebApi.csproj", "{4A3E58EA-729C-4527-8AA4-DFCD402B810E}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{4A3E58EA-729C-4527-8AA4-DFCD402B810E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{4A3E58EA-729C-4527-8AA4-DFCD402B810E}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{4A3E58EA-729C-4527-8AA4-DFCD402B810E}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{4A3E58EA-729C-4527-8AA4-DFCD402B810E}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using System.Web.Http; | ||
using System.Net.Http.Formatting; | ||
using Newtonsoft.Json; | ||
|
||
namespace Samples.WebApi.Config | ||
{ | ||
public static class WebApiConfig | ||
{ | ||
public static void Register(HttpConfiguration config) | ||
{ | ||
config.Routes.MapHttpRoute( | ||
name: "DefaultApi", | ||
routeTemplate: "api/{controller}/{action}/" | ||
); | ||
|
||
// Configure JSON formatter | ||
config.Formatters.Clear(); | ||
config.Formatters.Add(new JsonMediaTypeFormatter() | ||
{ | ||
SerializerSettings = new JsonSerializerSettings() | ||
{ | ||
#if DEBUG | ||
Formatting = Formatting.Indented | ||
#endif | ||
} | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using System; | ||
using System.Net.Http; | ||
using System.Net.Http.Headers; | ||
using System.Web.Http; | ||
|
||
namespace Samples.WebApi.Controllers | ||
{ | ||
public class HelloController : ApiController | ||
{ | ||
// GET Api/Hello/World/ | ||
[HttpGet] | ||
[ActionName("World")] | ||
public HttpResponseMessage HelloWorld() | ||
{ | ||
HttpResponseMessage response = new HttpResponseMessage(); | ||
response.Content = new StringContent("Hello world!"); | ||
response.Headers.CacheControl = new CacheControlHeaderValue(); | ||
response.Headers.CacheControl.MustRevalidate = true; | ||
response.Headers.CacheControl.MaxAge = TimeSpan.Zero; | ||
response.Headers.CacheControl.Private = true; | ||
return response; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{4A3E58EA-729C-4527-8AA4-DFCD402B810E}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>Samples.WebApi</RootNamespace> | ||
<AssemblyName>Samples.WebApi</AssemblyName> | ||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">.\</SolutionDir> | ||
<RestorePackages>true</RestorePackages> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="Microsoft.Owin, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> | ||
<SpecificVersion>False</SpecificVersion> | ||
<HintPath>..\packages\Microsoft.Owin.1.1.0-beta2\lib\net45\Microsoft.Owin.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> | ||
<SpecificVersion>False</SpecificVersion> | ||
<HintPath>..\packages\Newtonsoft.Json.5.0.6\lib\net45\Newtonsoft.Json.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Owin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f0ebd12fd5e55cc5, processorArchitecture=MSIL"> | ||
<SpecificVersion>False</SpecificVersion> | ||
<HintPath>..\packages\Owin.1.0\lib\net40\Owin.dll</HintPath> | ||
</Reference> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Net.Http" /> | ||
<Reference Include="System.Net.Http.Formatting, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> | ||
<SpecificVersion>False</SpecificVersion> | ||
<HintPath>..\packages\Microsoft.AspNet.WebApi.Client.5.0.0-beta2\lib\net45\System.Net.Http.Formatting.dll</HintPath> | ||
</Reference> | ||
<Reference Include="System.Web.Http, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> | ||
<SpecificVersion>False</SpecificVersion> | ||
<HintPath>..\packages\Microsoft.AspNet.WebApi.Core.5.0.0-beta2\lib\net45\System.Web.Http.dll</HintPath> | ||
</Reference> | ||
<Reference Include="System.Web.Http.Owin, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> | ||
<SpecificVersion>False</SpecificVersion> | ||
<HintPath>..\packages\Microsoft.AspNet.WebApi.Owin.5.0.0-beta2\lib\net45\System.Web.Http.Owin.dll</HintPath> | ||
</Reference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="Controllers\HelloController.cs" /> | ||
<Compile Include="Config\WebApiConfig.cs" /> | ||
<Compile Include="Startup.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="packages.config" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" /> | ||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
Other similar extension points exist, see Microsoft.Common.targets. | ||
<Target Name="BeforeBuild"> | ||
</Target> | ||
<Target Name="AfterBuild"> | ||
</Target> | ||
--> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Web.Http; | ||
using Owin; | ||
using Samples.WebApi.Config; | ||
|
||
namespace Samples.WebApi | ||
{ | ||
public class Startup | ||
{ | ||
public static void Configuration(IAppBuilder app) | ||
{ | ||
HttpConfiguration config = new HttpConfiguration(); | ||
WebApiConfig.Register(config); | ||
app.UseWebApi(config); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"dependencies": { | ||
"connect-owin": "0.0.1" | ||
}, | ||
"devDependencies": { | ||
"express": "~3.4.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="Microsoft.AspNet.WebApi.Client" version="5.0.0-beta2" targetFramework="net45" /> | ||
<package id="Microsoft.AspNet.WebApi.Core" version="5.0.0-beta2" targetFramework="net45" /> | ||
<package id="Microsoft.AspNet.WebApi.Owin" version="5.0.0-beta2" targetFramework="net45" /> | ||
<package id="Microsoft.Owin" version="1.1.0-beta2" targetFramework="net45" /> | ||
<package id="Newtonsoft.Json" version="5.0.6" targetFramework="net45" /> | ||
<package id="Owin" version="1.0" targetFramework="net45" /> | ||
</packages> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
var owin = require('connect-owin'), | ||
express = require('express'); | ||
|
||
var app = express(); | ||
app.all('/Api/*', owin(__dirname + '\\bin\\Debug\\Samples.WebApi.dll')); | ||
app.all('/node', function (req, res) { | ||
res.send(200, 'Hello from JavaScript! Time on server ' + new Date()); | ||
}); | ||
app.listen(3000); |