Skip to content

Commit 2b5de72

Browse files
committed
Initial commit
0 parents  commit 2b5de72

52 files changed

Lines changed: 3964 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 399 additions & 0 deletions
Large diffs are not rendered by default.

AspNetCore.sln

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "AspNetCore", "AspNetCore", "{7F209FD2-1190-4721-9A08-9569AB4AA8D5}"
4+
EndProject
5+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Zapto.AspNetCore.NetFx", "src\Zapto.AspNetCore.NetFx\Zapto.AspNetCore.NetFx.csproj", "{C3CEF02D-43F9-4C28-BC1D-18ED3D1FC0E4}"
6+
EndProject
7+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Sandbox", "Sandbox", "{DD6845EA-4012-4E0A-8B78-8BAE5FF6967B}"
8+
EndProject
9+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebFormsApp", "sandbox\WebFormsApp\WebFormsApp.csproj", "{77FA9DA3-FB50-46EC-B9B8-905121594EA1}"
10+
EndProject
11+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{B3DA0F06-4511-4791-BB12-A84655F02BFA}"
12+
EndProject
13+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Zapto.AspNetCore.NetFx.Tests", "tests\Zapto.AspNetCore.NetFx.Tests\Zapto.AspNetCore.NetFx.Tests.csproj", "{305C7374-1A54-4409-B527-968D49B258DF}"
14+
EndProject
15+
Global
16+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
17+
Debug|Any CPU = Debug|Any CPU
18+
Release|Any CPU = Release|Any CPU
19+
EndGlobalSection
20+
GlobalSection(NestedProjects) = preSolution
21+
{C3CEF02D-43F9-4C28-BC1D-18ED3D1FC0E4} = {7F209FD2-1190-4721-9A08-9569AB4AA8D5}
22+
{77FA9DA3-FB50-46EC-B9B8-905121594EA1} = {DD6845EA-4012-4E0A-8B78-8BAE5FF6967B}
23+
{305C7374-1A54-4409-B527-968D49B258DF} = {B3DA0F06-4511-4791-BB12-A84655F02BFA}
24+
EndGlobalSection
25+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
26+
{C3CEF02D-43F9-4C28-BC1D-18ED3D1FC0E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27+
{C3CEF02D-43F9-4C28-BC1D-18ED3D1FC0E4}.Debug|Any CPU.Build.0 = Debug|Any CPU
28+
{C3CEF02D-43F9-4C28-BC1D-18ED3D1FC0E4}.Release|Any CPU.ActiveCfg = Release|Any CPU
29+
{C3CEF02D-43F9-4C28-BC1D-18ED3D1FC0E4}.Release|Any CPU.Build.0 = Release|Any CPU
30+
{77FA9DA3-FB50-46EC-B9B8-905121594EA1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
31+
{77FA9DA3-FB50-46EC-B9B8-905121594EA1}.Debug|Any CPU.Build.0 = Debug|Any CPU
32+
{77FA9DA3-FB50-46EC-B9B8-905121594EA1}.Release|Any CPU.ActiveCfg = Release|Any CPU
33+
{77FA9DA3-FB50-46EC-B9B8-905121594EA1}.Release|Any CPU.Build.0 = Release|Any CPU
34+
{305C7374-1A54-4409-B527-968D49B258DF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
35+
{305C7374-1A54-4409-B527-968D49B258DF}.Debug|Any CPU.Build.0 = Debug|Any CPU
36+
{305C7374-1A54-4409-B527-968D49B258DF}.Release|Any CPU.ActiveCfg = Release|Any CPU
37+
{305C7374-1A54-4409-B527-968D49B258DF}.Release|Any CPU.Build.0 = Release|Any CPU
38+
EndGlobalSection
39+
EndGlobal

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 Zapto
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
using Microsoft.AspNetCore.Mvc;
2+
using WebFormsApp.Modules;
3+
4+
namespace WebFormsApp.Controllers
5+
{
6+
public class CounterController : ControllerBase
7+
{
8+
private readonly CounterService _counterService;
9+
10+
public CounterController(CounterService counterService)
11+
{
12+
_counterService = counterService;
13+
}
14+
15+
[HttpPost("handler/counter/reset")]
16+
public IActionResult Reset()
17+
{
18+
_counterService.Reset();
19+
return Ok("Counter reset.");
20+
}
21+
22+
[HttpPost("handler/counter/increment")]
23+
public IActionResult IncrementHandler()
24+
{
25+
return Ok($"Count: {_counterService.Increment()}");
26+
}
27+
28+
[HttpPost("module/counter/reset")]
29+
public IActionResult ResetModule()
30+
{
31+
_counterService.Reset();
32+
return Ok("Counter reset.");
33+
}
34+
35+
[HttpPost("module/counter/increment")]
36+
public IActionResult IncrementModule()
37+
{
38+
return Ok($"Count: {_counterService.Increment()}");
39+
}
40+
}
41+
}

sandbox/WebFormsApp/Global.asax

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<%@ Application Codebehind="Global.asax.cs" Inherits="WebFormsApp.MvcApplication" Language="C#" %>

sandbox/WebFormsApp/Global.asax.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
namespace WebFormsApp
2+
{
3+
public class MvcApplication : System.Web.HttpApplication
4+
{
5+
protected void Application_Start()
6+
{
7+
8+
}
9+
}
10+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
namespace WebFormsApp.Modules
2+
{
3+
public class CounterService
4+
{
5+
private int _count;
6+
7+
public int Increment() => ++_count;
8+
9+
public void Reset()
10+
{
11+
_count = 0;
12+
}
13+
}
14+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
using System;
2+
using System.Diagnostics;
3+
using System.Threading;
4+
using System.Threading.Tasks;
5+
using Zapto.AspNetCore;
6+
using Zapto.AspNetCore.Http;
7+
using Microsoft.AspNetCore.Builder;
8+
using Microsoft.AspNetCore.Http;
9+
using Microsoft.AspNetCore.Routing;
10+
using Microsoft.Extensions.Configuration;
11+
using Microsoft.Extensions.DependencyInjection;
12+
using Microsoft.Extensions.ObjectPool;
13+
14+
namespace WebFormsApp.Modules
15+
{
16+
public class TestModule : AspNetCoreModule
17+
{
18+
public override void ConfigureServices(IServiceCollection services)
19+
{
20+
services.AddOptions();
21+
services.AddLogging();
22+
services.AddMvcCore().AddApplicationPart(typeof(TestModule).Assembly);
23+
24+
services.AddSingleton<CounterService>();
25+
}
26+
27+
public override void Configure(IApplicationBuilder app)
28+
{
29+
app.UseMvc();
30+
31+
app.Use(async (context, next) =>
32+
{
33+
if (context.Request.Path.StartsWithSegments("/ws/echo") && context.WebSockets.IsWebSocketRequest)
34+
{
35+
var webSocket = await context.WebSockets.AcceptWebSocketAsync();
36+
var buffer = new byte[1024 * 4];
37+
38+
while (!context.RequestAborted.IsCancellationRequested)
39+
{
40+
var result = await webSocket.ReceiveAsync(new ArraySegment<byte>(buffer), context.RequestAborted);
41+
if (result.MessageType == System.Net.WebSockets.WebSocketMessageType.Close)
42+
{
43+
await webSocket.CloseAsync(System.Net.WebSockets.WebSocketCloseStatus.NormalClosure, "Closing", CancellationToken.None);
44+
break;
45+
}
46+
47+
await webSocket.SendAsync(new ArraySegment<byte>(buffer, 0, result.Count), result.MessageType, result.EndOfMessage, CancellationToken.None);
48+
}
49+
50+
return;
51+
}
52+
53+
await next();
54+
});
55+
}
56+
}
57+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("WebFormsApp")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("WebFormsApp")]
13+
[assembly: AssemblyCopyright("Copyright © 2025")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("77FA9DA3-FB50-46EC-B9B8-905121594EA1")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Revision and Build Numbers
33+
// by using the '*' as shown below:
34+
[assembly: AssemblyVersion("1.0.0.0")]
35+
[assembly: AssemblyFileVersion("1.0.0.0")]
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?xml version="1.0"?>
2+
3+
<!-- For more information on using Web.config transformation visit https://go.microsoft.com/fwlink/?LinkId=301874 -->
4+
5+
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
6+
<!--
7+
In the example below, the "SetAttributes" transform will change the value of
8+
"connectionString" to use "ReleaseSQLServer" only when the "Match" locator
9+
finds an attribute "name" that has a value of "MyDB".
10+
11+
<connectionStrings>
12+
<add name="MyDB"
13+
connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True"
14+
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
15+
</connectionStrings>
16+
-->
17+
<system.web>
18+
<!--
19+
In the example below, the "Replace" transform will replace the entire
20+
<customErrors> section of your Web.config file.
21+
Note that because there is only one customErrors section under the
22+
<system.web> node, there is no need to use the "xdt:Locator" attribute.
23+
24+
<customErrors defaultRedirect="GenericError.htm"
25+
mode="RemoteOnly" xdt:Transform="Replace">
26+
<error statusCode="500" redirect="InternalError.htm"/>
27+
</customErrors>
28+
-->
29+
</system.web>
30+
</configuration>

0 commit comments

Comments
 (0)