未验证 提交 b5e5ef62 编写于 作者: G github-actions[bot] 提交者: GitHub

[release/7.0] Update a few dependencies (#78710)

* Update a few dependencies

Fix some component governance warnings.

* Remove System.Reflection.MetadataLoadContext reference that was also get through Microsoft.Build

* Update NugetPackagingVersion and NugetProjectModelVersion to 6.2.2

* Bump System.Data.SqlClient to 4.8.5 (#78774)

It addresses a component governance warning.

(cherry picked from commit fcff8576)

* Remove code for CoreFxNetCloudService classic Azure Cloud Service (#78773)

It was replaced by a new endpoint (see https://github.com/dotnet/corefx/pull/41603) and the corefx-net.cloudapp.net endpoint was turned off.

(cherry picked from commit da1afc8c)
Co-authored-by: NJakob Botsch Nielsen <jakob.botsch.nielsen@gmail.com>
Co-authored-by: NAlexander Köplinger <alex.koeplinger@outlook.com>
上级 e13ac7ab
......@@ -103,14 +103,14 @@
<SystemBuffersVersion>4.5.1</SystemBuffersVersion>
<SystemCollectionsImmutableVersion>6.0.0</SystemCollectionsImmutableVersion>
<SystemComponentModelAnnotationsVersion>5.0.0</SystemComponentModelAnnotationsVersion>
<SystemDataSqlClientVersion>4.8.3</SystemDataSqlClientVersion>
<SystemDataSqlClientVersion>4.8.5</SystemDataSqlClientVersion>
<SystemDataDataSetExtensionsVersion>4.5.0</SystemDataDataSetExtensionsVersion>
<SystemIOFileSystemAccessControlVersion>5.0.0</SystemIOFileSystemAccessControlVersion>
<SystemIOPipesAccessControlVersion>5.0.0</SystemIOPipesAccessControlVersion>
<SystemMemoryVersion>4.5.5</SystemMemoryVersion>
<SystemNumericsVectorsVersion>4.5.0</SystemNumericsVectorsVersion>
<SystemReflectionMetadataVersion>6.0.1</SystemReflectionMetadataVersion>
<SystemReflectionMetadataLoadContextVersion>4.7.1</SystemReflectionMetadataLoadContextVersion>
<SystemReflectionMetadataLoadContextVersion>6.0.0</SystemReflectionMetadataLoadContextVersion>
<SystemReflectionEmitVersion>4.7.0</SystemReflectionEmitVersion>
<SystemReflectionEmitILGenerationVersion>4.7.0</SystemReflectionEmitILGenerationVersion>
<SystemReflectionEmitLightweightVersion>4.7.0</SystemReflectionEmitLightweightVersion>
......@@ -155,10 +155,10 @@
<NetStandardLibraryVersion>2.0.3</NetStandardLibraryVersion>
<MicrosoftDiagnosticsToolsRuntimeClientVersion>1.0.4-preview6.19326.1</MicrosoftDiagnosticsToolsRuntimeClientVersion>
<DNNEVersion>1.0.27</DNNEVersion>
<MicrosoftBuildVersion>16.10.0</MicrosoftBuildVersion>
<MicrosoftBuildVersion>17.3.2</MicrosoftBuildVersion>
<MicrosoftBuildTasksCoreVersion>$(MicrosoftBuildVersion)</MicrosoftBuildTasksCoreVersion>
<NugetProjectModelVersion>6.2.1</NugetProjectModelVersion>
<NugetPackagingVersion>6.2.1</NugetPackagingVersion>
<NugetProjectModelVersion>6.2.2</NugetProjectModelVersion>
<NugetPackagingVersion>6.2.2</NugetPackagingVersion>
<!-- Testing -->
<MicrosoftNETCoreCoreDisToolsVersion>1.1.0</MicrosoftNETCoreCoreDisToolsVersion>
<MicrosoftNETTestSdkVersion>17.4.0-preview-20220707-01</MicrosoftNETTestSdkVersion>
......
......@@ -38,10 +38,3 @@ This will join all machines to a test Active Directory and enable Windows Remoti
Running as the Active Directory Administrator, run .\setup.ps1 from any of the machines within the environment.
The script will use WinRM to connect and update all other roles.
## Deployment Instructions to update the Azure-based environment
1. Create a _Classic_ Azure WebService role.
2. Create a server certificate and add it to the subscription with the name: `CoreFxNetCertificate`
3. Edit `Servers\CoreFxNetCloudService\CoreFxNetCloudService\ServiceConfiguration.Cloud.cscfg` and ensure that the `CoreFxNetCertificate` `thumbprint` and `thumbprintAlgorithm` are correct.
4. Open the solution in Visual Studio and Run the Azure Publishing wizard to create and deploy the application.

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25123.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{CC5FD16D-436D-48AD-A40C-5A424C6E3E79}") = "CoreFxNetCloudService", "CoreFxNetCloudService\CoreFxNetCloudService.ccproj", "{57E639CE-BD4D-4CB3-A913-AE51E18CD4A0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebServer", "WebServer\WebServer.csproj", "{6ACFF710-5F63-4E46-B0DA-0D1FE36EF4A7}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{57E639CE-BD4D-4CB3-A913-AE51E18CD4A0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{57E639CE-BD4D-4CB3-A913-AE51E18CD4A0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{57E639CE-BD4D-4CB3-A913-AE51E18CD4A0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{57E639CE-BD4D-4CB3-A913-AE51E18CD4A0}.Release|Any CPU.Build.0 = Release|Any CPU
{6ACFF710-5F63-4E46-B0DA-0D1FE36EF4A7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6ACFF710-5F63-4E46-B0DA-0D1FE36EF4A7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6ACFF710-5F63-4E46-B0DA-0D1FE36EF4A7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6ACFF710-5F63-4E46-B0DA-0D1FE36EF4A7}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
<Project DefaultTargets="Build">
<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>
<ProductVersion>2.9</ProductVersion>
<ProjectGuid>57e639ce-bd4d-4cb3-a913-ae51e18cd4a0</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>CoreFxNetCloudService</RootNamespace>
<AssemblyName>CoreFxNetCloudService</AssemblyName>
<StartDevelopmentStorage>True</StartDevelopmentStorage>
<Name>CoreFxNetCloudService</Name>
<PackageEnableRemoteDebugger>False</PackageEnableRemoteDebugger>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
</PropertyGroup>
<!-- Items for the project -->
<ItemGroup>
<ServiceDefinition Include="ServiceDefinition.csdef" />
<ServiceConfiguration Include="ServiceConfiguration.Local.cscfg" />
<ServiceConfiguration Include="ServiceConfiguration.Cloud.cscfg" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\WebServer\WebServer.csproj">
<Name>WebServer</Name>
<Project>{6acff710-5f63-4e46-b0da-0d1fe36ef4a7}</Project>
<Private>True</Private>
<RoleType>Web</RoleType>
<RoleName>WebServer</RoleName>
<UpdateDiagnosticsConnectionStringOnPublish>True</UpdateDiagnosticsConnectionStringOnPublish>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Folder Include="WebServerContent\" />
</ItemGroup>
<ItemGroup>
<DiagnosticsConfiguration Include="WebServerContent\diagnostics.wadcfgx" />
</ItemGroup>
<!-- Import the target files for this project template -->
<PropertyGroup>
<VisualStudioVersion Condition=" '$(VisualStudioVersion)' == '' ">10.0</VisualStudioVersion>
<CloudExtensionsDir Condition=" '$(CloudExtensionsDir)' == '' ">$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Windows Azure Tools\2.9\</CloudExtensionsDir>
</PropertyGroup>
<Import Project="$(CloudExtensionsDir)Microsoft.WindowsAzure.targets" />
</Project>
<ServiceConfiguration serviceName="CoreFxNetCloudService" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration" osFamily="4" osVersion="*" schemaVersion="2015-04.2.6">
<Role name="WebServer">
<Certificates>
<Certificate name="CoreFxNetCertificate" thumbprint="c8b01fb0b555e620fdfb7ae33de8e520c2ebe872" thumbprintAlgorithm="sha1" />
<Certificate name="Microsoft.WindowsAzure.Plugins.RemoteAccess.PasswordEncryption" thumbprint="5439D7FF5B2041A2EC0B3DD7D6128C7E577D649F" thumbprintAlgorithm="sha1" />
</Certificates>
<Instances count="2" />
<ConfigurationSettings>
<Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="UseDevelopmentStorage=false" />
<Setting name="Microsoft.WindowsAzure.Plugins.RemoteAccess.Enabled" value="" />
<Setting name="Microsoft.WindowsAzure.Plugins.RemoteAccess.AccountUsername" value="" />
<Setting name="Microsoft.WindowsAzure.Plugins.RemoteAccess.AccountEncryptedPassword" value="" />
<Setting name="Microsoft.WindowsAzure.Plugins.RemoteAccess.AccountExpiration" value="" />
<Setting name="Microsoft.WindowsAzure.Plugins.RemoteForwarder.Enabled" value="" />
</ConfigurationSettings>
</Role>
</ServiceConfiguration>
\ No newline at end of file
<ServiceConfiguration serviceName="CoreFxNetCloudService" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration" osFamily="4" osVersion="*" schemaVersion="2015-04.2.6">
<Role name="WebServer">
<Certificates>
<Certificate name="CoreFxNetCertificate" thumbprint="c8b01fb0b555e620fdfb7ae33de8e520c2ebe872" thumbprintAlgorithm="sha1" />
<Certificate name="Microsoft.WindowsAzure.Plugins.RemoteAccess.PasswordEncryption" thumbprint="5439D7FF5B2041A2EC0B3DD7D6128C7E577D649F" thumbprintAlgorithm="sha1" />
</Certificates>
<Instances count="1" />
<ConfigurationSettings>
<Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="UseDevelopmentStorage=true" />
<Setting name="Microsoft.WindowsAzure.Plugins.RemoteAccess.Enabled" value="" />
<Setting name="Microsoft.WindowsAzure.Plugins.RemoteAccess.AccountUsername" value="" />
<Setting name="Microsoft.WindowsAzure.Plugins.RemoteAccess.AccountEncryptedPassword" value="" />
<Setting name="Microsoft.WindowsAzure.Plugins.RemoteAccess.AccountExpiration" value="" />
<Setting name="Microsoft.WindowsAzure.Plugins.RemoteForwarder.Enabled" value="" />
</ConfigurationSettings>
</Role>
</ServiceConfiguration>
\ No newline at end of file
<ServiceDefinition name="CoreFxNetCloudService" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition" schemaVersion="2015-04.2.6">
<WebRole name="WebServer" vmsize="Medium">
<Certificates>
<Certificate name="CoreFxNetCertificate" storeLocation="LocalMachine" storeName="My" />
</Certificates>
<Sites>
<Site name="Web">
<Bindings>
<Binding name="Endpoint1" endpointName="Endpoint1" />
<Binding name="HttpsIn" endpointName="HttpsIn" />
</Bindings>
</Site>
</Sites>
<ConfigurationSettings>
<Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" />
</ConfigurationSettings>
<Endpoints>
<InputEndpoint name="Endpoint1" protocol="http" port="80" />
<InputEndpoint name="HttpsIn" protocol="https" port="443" certificate="CoreFxNetCertificate" />
</Endpoints>
<Imports>
<Import moduleName="RemoteAccess" />
<Import moduleName="RemoteForwarder" />
</Imports>
</WebRole>
</ServiceDefinition>
\ No newline at end of file
<DiagnosticsConfiguration xmlns="http://schemas.microsoft.com/ServiceHosting/2010/10/DiagnosticsConfiguration">
<PublicConfig>
<WadCfg>
<DiagnosticMonitorConfiguration overallQuotaInMB="4096">
<DiagnosticInfrastructureLogs scheduledTransferLogLevelFilter="Error"/>
<Logs scheduledTransferPeriod="PT1M" scheduledTransferLogLevelFilter="Error" />
<Directories scheduledTransferPeriod="PT1M">
<IISLogs containerName ="wad-iis-logfiles" />
<FailedRequestLogs containerName ="wad-failedrequestlogs" />
</Directories>
<WindowsEventLog scheduledTransferPeriod="PT1M" >
<DataSource name="Application!*[System[(Level=1 or Level=2 or Level=3)]]" />
<DataSource name="Windows Azure!*[System[(Level=1 or Level=2 or Level=3 or Level=4)]]" />
</WindowsEventLog>
<CrashDumps containerName="wad-crashdumps" dumpType="Mini">
<CrashDumpConfiguration processName="WaIISHost.exe"/>
<CrashDumpConfiguration processName="WaWorkerHost.exe"/>
<CrashDumpConfiguration processName="w3wp.exe"/>
</CrashDumps>
<PerformanceCounters scheduledTransferPeriod="PT1M">
<PerformanceCounterConfiguration counterSpecifier="\Memory\Available MBytes" sampleRate="PT3M" />
<PerformanceCounterConfiguration counterSpecifier="\Web Service(_Total)\ISAPI Extension Requests/sec" sampleRate="PT3M" />
<PerformanceCounterConfiguration counterSpecifier="\Web Service(_Total)\Bytes Total/Sec" sampleRate="PT3M" />
<PerformanceCounterConfiguration counterSpecifier="\ASP.NET Applications(__Total__)\Requests/Sec" sampleRate="PT3M" />
<PerformanceCounterConfiguration counterSpecifier="\ASP.NET Applications(__Total__)\Errors Total/Sec" sampleRate="PT3M" />
<PerformanceCounterConfiguration counterSpecifier="\ASP.NET\Requests Queued" sampleRate="PT3M" />
<PerformanceCounterConfiguration counterSpecifier="\ASP.NET\Requests Rejected" sampleRate="PT3M" />
<PerformanceCounterConfiguration counterSpecifier="\Processor(_Total)\% Processor Time" sampleRate="PT3M" />
</PerformanceCounters>
</DiagnosticMonitorConfiguration>
</WadCfg>
<StorageAccount></StorageAccount>
</PublicConfig>
<PrivateConfig>
<StorageAccount name="" key="" endpoint="" />
</PrivateConfig>
<IsEnabled>true</IsEnabled>
</DiagnosticsConfiguration>
\ No newline at end of file
<DiagnosticsConfiguration xmlns="http://schemas.microsoft.com/ServiceHosting/2010/10/DiagnosticsConfiguration">
<PublicConfig xmlns="http://schemas.microsoft.com/ServiceHosting/2010/10/DiagnosticsConfiguration">
<WadCfg>
<DiagnosticMonitorConfiguration overallQuotaInMB="4096">
<DiagnosticInfrastructureLogs scheduledTransferLogLevelFilter="Error" />
<Logs scheduledTransferPeriod="PT1M" scheduledTransferLogLevelFilter="Error" />
<Directories scheduledTransferPeriod="PT1M">
<IISLogs containerName="wad-iis-logfiles" />
<FailedRequestLogs containerName="wad-failedrequestlogs" />
</Directories>
<WindowsEventLog scheduledTransferPeriod="PT1M">
<DataSource name="Application!*[System[(Level=1 or Level=2 or Level=3)]]" />
<DataSource name="Windows Azure!*[System[(Level=1 or Level=2 or Level=3 or Level=4)]]" />
</WindowsEventLog>
<CrashDumps containerName="wad-crashdumps" dumpType="Mini">
<CrashDumpConfiguration processName="WaIISHost.exe" />
<CrashDumpConfiguration processName="WaWorkerHost.exe" />
<CrashDumpConfiguration processName="w3wp.exe" />
</CrashDumps>
<PerformanceCounters scheduledTransferPeriod="PT1M">
<PerformanceCounterConfiguration counterSpecifier="\Memory\Available MBytes" sampleRate="PT3M" />
<PerformanceCounterConfiguration counterSpecifier="\Web Service(_Total)\ISAPI Extension Requests/sec" sampleRate="PT3M" />
<PerformanceCounterConfiguration counterSpecifier="\Web Service(_Total)\Bytes Total/Sec" sampleRate="PT3M" />
<PerformanceCounterConfiguration counterSpecifier="\ASP.NET Applications(__Total__)\Requests/Sec" sampleRate="PT3M" />
<PerformanceCounterConfiguration counterSpecifier="\ASP.NET Applications(__Total__)\Errors Total/Sec" sampleRate="PT3M" />
<PerformanceCounterConfiguration counterSpecifier="\ASP.NET\Requests Queued" sampleRate="PT3M" />
<PerformanceCounterConfiguration counterSpecifier="\ASP.NET\Requests Rejected" sampleRate="PT3M" />
<PerformanceCounterConfiguration counterSpecifier="\Processor(_Total)\% Processor Time" sampleRate="PT3M" />
</PerformanceCounters>
</DiagnosticMonitorConfiguration>
</WadCfg>
<StorageAccount>devstoreaccount1</StorageAccount>
</PublicConfig>
<PrivateConfig xmlns="http://schemas.microsoft.com/ServiceHosting/2010/10/DiagnosticsConfiguration">
<StorageAccount name="devstoreaccount1" key="Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==" />
</PrivateConfig>
<IsEnabled>true</IsEnabled>
</DiagnosticsConfiguration>
\ No newline at end of file
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
namespace WebServer
{
public static class AuthenticationHelper
{
public static bool HandleAuthentication(HttpContext context)
{
string authType = context.Request.QueryString["auth"];
string user = context.Request.QueryString["user"];
string password = context.Request.QueryString["password"];
string domain = context.Request.QueryString["domain"];
if (string.Equals("basic", authType, StringComparison.OrdinalIgnoreCase))
{
if (!HandleBasicAuthentication(context, user, password, domain))
{
context.Response.End();
return false;
}
}
else if (string.Equals("Negotiate", authType, StringComparison.OrdinalIgnoreCase) ||
string.Equals("NTLM", authType, StringComparison.OrdinalIgnoreCase))
{
if (!HandleChallengeResponseAuthentication(context, authType, user, password, domain))
{
context.Response.End();
return false;
}
}
else if (authType != null)
{
context.Response.StatusCode = 501;
context.Response.StatusDescription = "Unsupported auth type: " + authType;
context.Response.End();
return false;
}
return true;
}
private static bool HandleBasicAuthentication(HttpContext context, string user, string password, string domain)
{
const string WwwAuthenticateHeaderValue = "Basic realm=\"corefx-networking\"";
string authHeader = context.Request.Headers["Authorization"];
if (authHeader == null)
{
context.Response.StatusCode = 401;
context.Response.Headers.Add("WWW-Authenticate", WwwAuthenticateHeaderValue);
return false;
}
string[] split = authHeader.Split(new char[] { ' ' });
if (split.Length < 2)
{
context.Response.StatusCode = 500;
context.Response.StatusDescription = "Invalid Authorization header: " + authHeader;
return false;
}
if (!string.Equals("basic", split[0], StringComparison.OrdinalIgnoreCase))
{
context.Response.StatusCode = 500;
context.Response.StatusDescription = "Unsupported auth type: " + split[0];
return false;
}
// Decode base64 username:password.
byte[] bytes = Convert.FromBase64String(split[1]);
string credential = Encoding.ASCII.GetString(bytes);
string[] pair = credential.Split(new char[] { ':' });
// Prefix "domain\" to username if domain is specified.
if (domain != null)
{
user = domain + "\\" + user;
}
if (pair.Length != 2 || pair[0] != user || pair[1] != password)
{
context.Response.StatusCode = 401;
context.Response.Headers.Add("WWW-Authenticate", WwwAuthenticateHeaderValue);
return false;
}
// Success.
return true;
}
private static bool HandleChallengeResponseAuthentication(
HttpContext context,
string authType,
string user,
string password,
string domain)
{
string authHeader = context.Request.Headers["Authorization"];
if (authHeader == null)
{
context.Response.StatusCode = 401;
context.Response.Headers.Add("WWW-Authenticate", authType);
return false;
}
// We don't fully support this authentication method.
context.Response.StatusCode = 501;
context.Response.StatusDescription = string.Format(
"Attempt to use unsupported challenge/response auth type. {0}: {1}",
authType,
authHeader);
return false;
}
}
}
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.IO;
using System.IO.Compression;
using System.Security.Cryptography;
using System.Text;
namespace WebServer
{
public static class ContentHelper
{
public static byte[] GetDeflateBytes(string data)
{
byte[] bytes = Encoding.UTF8.GetBytes(data);
var compressedStream = new MemoryStream();
using (var compressor = new DeflateStream(compressedStream, CompressionMode.Compress, true))
{
compressor.Write(bytes, 0, bytes.Length);
}
return compressedStream.ToArray();
}
public static byte[] GetGZipBytes(string data)
{
byte[] bytes = Encoding.UTF8.GetBytes(data);
var compressedStream = new MemoryStream();
using (var compressor = new GZipStream(compressedStream, CompressionMode.Compress, true))
{
compressor.Write(bytes, 0, bytes.Length);
}
return compressedStream.ToArray();
}
public static byte[] ComputeMD5Hash(string data)
{
return ComputeMD5Hash(Encoding.UTF8.GetBytes(data));
}
public static byte[] ComputeMD5Hash(byte[] data)
{
using (MD5 md5 = MD5.Create())
{
return md5.ComputeHash(data);
}
}
}
}
<%@ WebHandler Language="C#" CodeBehind="Deflate.ashx.cs" Class="WebServer.Deflate" %>
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Web;
namespace WebServer
{
/// <summary>
/// Summary description for Deflate
/// </summary>
public class Deflate : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
string responseBody = "Sending DEFLATE compressed";
context.Response.Headers.Add("Content-MD5", Convert.ToBase64String(ContentHelper.ComputeMD5Hash(responseBody)));
context.Response.Headers.Add("Content-Encoding", "deflate");
context.Response.ContentType = "text/plain";
byte[] bytes = ContentHelper.GetDeflateBytes(responseBody);
context.Response.BinaryWrite(bytes);
}
public bool IsReusable
{
get
{
return true;
}
}
}
}
<%@ WebHandler Language="C#" CodeBehind="Echo.ashx.cs" Class="WebServer.Echo" %>
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Security.Cryptography;
using System.Text;
using System.Web;
namespace WebServer
{
public class Echo : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
RequestHelper.AddResponseCookies(context);
if (!AuthenticationHelper.HandleAuthentication(context))
{
context.Response.End();
return;
}
// Add original request method verb as a custom response header.
context.Response.Headers.Add("X-HttpRequest-Method", context.Request.HttpMethod);
// Echo back JSON encoded payload.
RequestInformation info = RequestInformation.Create(context.Request);
string echoJson = info.SerializeToJson();
// Compute MD5 hash to clients can verify the received data.
using (MD5 md5 = MD5.Create())
{
byte[] bytes = Encoding.UTF8.GetBytes(echoJson);
byte[] hash = md5.ComputeHash(bytes);
string encodedHash = Convert.ToBase64String(hash);
context.Response.Headers.Add("Content-MD5", encodedHash);
context.Response.ContentType = "application/json";
context.Response.Write(echoJson);
}
context.Response.End();
}
public bool IsReusable
{
get
{
return true;
}
}
}
}
<%@ WebHandler Language="C#" CodeBehind="EmptyContent.ashx.cs" Class="WebServer.EmptyContent" %>
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace WebServer
{
/// <summary>
/// Summary description for EmptyContent
/// </summary>
public class EmptyContent : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
// By default, this empty method sends back a 200 status code with 'Content-Length: 0' response header.
// There are no other entity-body related (i.e. 'Content-Type') headers returned.
}
public bool IsReusable
{
get
{
return true;
}
}
}
}
<%@ WebHandler Language="C#" CodeBehind="GZip.ashx.cs" Class="WebServer.GZip" %>
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Web;
namespace WebServer
{
/// <summary>
/// Summary description for Gzip
/// </summary>
public class GZip : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
string responseBody = "Sending GZIP compressed";
context.Response.Headers.Add("Content-MD5", Convert.ToBase64String(ContentHelper.ComputeMD5Hash(responseBody)));
context.Response.Headers.Add("Content-Encoding", "gzip");
context.Response.ContentType = "text/plain";
byte[] bytes = ContentHelper.GetGZipBytes(responseBody);
context.Response.BinaryWrite(bytes);
}
public bool IsReusable
{
get
{
return false;
}
}
}
}
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Collections.Specialized;
using Newtonsoft.Json;
namespace WebServer
{
public class NameValueCollectionConverter : JsonConverter
{
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
var collection = value as NameValueCollection;
if (collection == null)
{
return;
}
writer.Formatting = Formatting.Indented;
writer.WriteStartObject();
foreach (var key in collection.AllKeys)
{
writer.WritePropertyName(key);
writer.WriteValue(collection.Get(key));
}
writer.WriteEndObject();
}
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
var nameValueCollection = new NameValueCollection();
var key = "";
while (reader.Read())
{
if (reader.TokenType == JsonToken.StartObject)
{
nameValueCollection = new NameValueCollection();
}
if (reader.TokenType == JsonToken.EndObject)
{
return nameValueCollection;
}
if (reader.TokenType == JsonToken.PropertyName)
{
key = reader.Value.ToString();
}
if (reader.TokenType == JsonToken.String)
nameValueCollection.Add(key, reader.Value.ToString());
}
return nameValueCollection;
}
public override bool CanConvert(Type objectType)
{
return IsTypeDerivedFromType(objectType, typeof(NameValueCollection));
}
private bool IsTypeDerivedFromType(Type childType, Type parentType)
{
Type testType = childType;
while (testType != null)
{
if (testType == parentType)
{
return true;
}
testType = testType.BaseType;
}
return false;
}
}
}
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("WebServer")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("WebServer")]
[assembly: AssemblyCopyright("Copyright \u00A9 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
<?xml version="1.0" encoding="utf-8"?>
<!--
This file is used by the publish/package process of your Web project. You can customize the behavior of this process
by editing this MSBuild file. In order to learn more about this please visit http://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>FileSystem</WebPublishMethod>
<LastUsedBuildConfiguration>Debug</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<ExcludeApp_Data>False</ExcludeApp_Data>
<publishUrl>.\PublishToIIS</publishUrl>
<DeleteExistingFiles>False</DeleteExistingFiles>
</PropertyGroup>
</Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<!--
This file is used by the publish/package process of your Web project. You can customize the behavior of this process
by editing this MSBuild file. In order to learn more about this please visit http://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>FileSystem</WebPublishMethod>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<ExcludeApp_Data>False</ExcludeApp_Data>
<publishUrl>.\PublishToIIS</publishUrl>
<DeleteExistingFiles>False</DeleteExistingFiles>
</PropertyGroup>
</Project>
\ No newline at end of file
<%@ WebHandler Language="C#" CodeBehind="Redirect.ashx.cs" Class="WebServer.Redirect" %>
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Web;
namespace WebServer
{
/// <summary>
/// Summary description for Redirect
/// </summary>
public class Redirect : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
int statusCode = 302;
string statusCodeString = context.Request.QueryString["statuscode"];
if (!string.IsNullOrEmpty(statusCodeString))
{
try
{
statusCode = int.Parse(statusCodeString);
if (statusCode < 300 || statusCode > 307)
{
context.Response.StatusCode = 500;
context.Response.StatusDescription = "Invalid redirect statuscode: " + statusCodeString;
return;
}
}
catch (Exception)
{
context.Response.StatusCode = 500;
context.Response.StatusDescription = "Error parsing statuscode: " + statusCodeString;
return;
}
}
string redirectUri = context.Request.QueryString["uri"];
if (string.IsNullOrEmpty(redirectUri))
{
context.Response.StatusCode = 500;
context.Response.StatusDescription = "Missing redirection uri";
return;
}
string hopsString = context.Request.QueryString["hops"];
int hops = 1;
if (!string.IsNullOrEmpty(hopsString))
{
try
{
hops = int.Parse(hopsString);
}
catch (Exception)
{
context.Response.StatusCode = 500;
context.Response.StatusDescription = "Error parsing hops: " + hopsString;
return;
}
}
RequestHelper.AddResponseCookies(context);
if (hops <= 1)
{
context.Response.Headers.Add("Location", redirectUri);
}
else
{
context.Response.Headers.Add(
"Location",
string.Format("/Redirect.ashx?uri={0}&hops={1}",
redirectUri,
hops - 1));
}
context.Response.StatusCode = statusCode;
}
public bool IsReusable
{
get
{
return true;
}
}
}
}
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Net;
using System.Web;
namespace WebServer
{
public static class RequestHelper
{
public static void AddResponseCookies(HttpContext context)
{
// Turn all 'X-SetCookie' request headers into 'Set-Cookie' response headers.
string headerName;
string headerValue;
for (int i = 0; i < context.Request.Headers.Count; i++)
{
headerName = context.Request.Headers.Keys[i];
headerValue = context.Request.Headers[i];
if (string.Equals(headerName, "X-SetCookie", StringComparison.OrdinalIgnoreCase))
{
context.Response.Headers.Add("Set-Cookie", headerValue);
}
}
}
public static CookieCollection GetRequestCookies(HttpRequest request)
{
var cookieCollection = new CookieCollection();
HttpCookieCollection cookies = request.Cookies;
for (int i = 0; i < cookies.Count; i++)
{
var cookie = new Cookie(cookies[i].Name, cookies[i].Value);
cookieCollection.Add(cookie);
}
return cookieCollection;
}
}
}
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Collections.Specialized;
using System.IO;
using System.Net;
using System.Web;
using Newtonsoft.Json;
namespace WebServer
{
public class RequestInformation
{
public string Method { get; private set; }
public string Url { get; private set; }
public NameValueCollection Headers { get; private set; }
public NameValueCollection Cookies { get; private set; }
public string BodyContent { get; private set; }
public int BodyLength { get; private set; }
public bool SecureConnection { get; private set; }
public bool ClientCertificatePresent { get; private set; }
public HttpClientCertificate ClientCertificate { get; private set; }
public static RequestInformation Create(HttpRequest request)
{
var info = new RequestInformation();
info.Method = request.HttpMethod;
info.Url = request.RawUrl;
info.Headers = request.Headers;
var cookies = new NameValueCollection();
CookieCollection cookieCollection = RequestHelper.GetRequestCookies(request);
foreach (Cookie cookie in cookieCollection)
{
cookies.Add(cookie.Name, cookie.Value);
}
info.Cookies = cookies;
Stream stream = request.GetBufferedInputStream();
using (var reader = new StreamReader(stream))
{
string body = reader.ReadToEnd();
info.BodyContent = body;
info.BodyLength = body.Length;
}
info.SecureConnection = request.IsSecureConnection;
var cs = request.ClientCertificate;
info.ClientCertificatePresent = cs.IsPresent;
if (cs.IsPresent)
{
info.ClientCertificate = request.ClientCertificate;
}
return info;
}
public static RequestInformation DeSerializeFromJson(string json)
{
return (RequestInformation)JsonConvert.DeserializeObject(
json,
typeof(RequestInformation),
new NameValueCollectionConverter());
}
public string SerializeToJson()
{
return JsonConvert.SerializeObject(this, new NameValueCollectionConverter());
}
private RequestInformation()
{
}
}
}
<%@ WebHandler Language="C#" CodeBehind="StatusCode.ashx.cs" Class="WebServer.StatusCode" %>
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Web;
namespace WebServer
{
public class StatusCode : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
string statusCodeString = context.Request.QueryString["statuscode"];
string statusDescription = context.Request.QueryString["statusdescription"];
try
{
int statusCode = int.Parse(statusCodeString);
context.Response.StatusCode = statusCode;
if (statusDescription != null)
{
context.Response.StatusDescription = statusDescription;
}
}
catch (Exception)
{
context.Response.StatusCode = 500;
context.Response.StatusDescription = "Error parsing statuscode: " + statusCodeString;
}
}
public bool IsReusable
{
get
{
return true;
}
}
}
}
<%@ WebHandler Language="C#" CodeBehind="Test.ashx.cs" Class="WebServer.Test" %>
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Net;
using System.Net.Http;
using System.Security.Cryptography;
using System.Text;
using System.Web;
using Newtonsoft.Json;
namespace WebServer
{
public class Test : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
RequestInformation info = RequestInformation.Create(context.Request);
string echoJson = info.SerializeToJson();
// Compute MD5 hash to clients can verify the received data.
MD5 md5 = MD5.Create();
byte[] bytes = Encoding.ASCII.GetBytes(echoJson);
var hash = md5.ComputeHash(bytes);
string encodedHash = Convert.ToBase64String(hash);
context.Response.Headers.Add("Content-MD5", encodedHash);
RequestInformation newEcho = RequestInformation.DeSerializeFromJson(echoJson);
context.Response.ContentType = "text/plain"; //"application/json";
context.Response.Write(echoJson);
}
public bool IsReusable
{
get
{
return false;
}
}
}
}
<%@ WebHandler Language="C#" CodeBehind="VerifyUpload.ashx.cs" Class="WebServer.VerifyUpload" %>
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.IO;
using System.Security.Cryptography;
using System.Web;
namespace WebServer
{
public class VerifyUpload : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
// Report back original request method verb.
context.Response.Headers.Add("X-HttpRequest-Method", context.Request.HttpMethod);
// Report back original entity-body related request headers.
string contentLength = context.Request.Headers["Content-Length"];
if (!string.IsNullOrEmpty(contentLength))
{
context.Response.Headers.Add("X-HttpRequest-Headers-ContentLength", contentLength);
}
string transferEncoding = context.Request.Headers["Transfer-Encoding"];
if (!string.IsNullOrEmpty(transferEncoding))
{
context.Response.Headers.Add("X-HttpRequest-Headers-TransferEncoding", transferEncoding);
}
// Get expected MD5 hash of request body.
string expectedHash = context.Request.Headers["Content-MD5"];
if (string.IsNullOrEmpty(expectedHash))
{
context.Response.StatusCode = 500;
context.Response.StatusDescription = "Missing 'Content-MD5' request header";
return;
}
// Compute MD5 hash of received request body.
string actualHash;
using (MD5 md5 = MD5.Create())
{
byte[] hash = md5.ComputeHash(ReadAllRequestBytes(context));
actualHash = Convert.ToBase64String(hash);
}
if (expectedHash == actualHash)
{
context.Response.StatusCode = 200;
}
else
{
context.Response.StatusCode = 500;
context.Response.StatusDescription = "Request body not verfied";
}
}
public bool IsReusable
{
get
{
return true;
}
}
private static byte[] ReadAllRequestBytes(HttpContext context)
{
Stream requestStream = context.Request.GetBufferedInputStream();
byte[] buffer = new byte[16 * 1024];
using (MemoryStream ms = new MemoryStream())
{
int read;
while ((read = requestStream.Read(buffer, 0, buffer.Length)) > 0)
{
ms.Write(buffer, 0, read);
}
return ms.ToArray();
}
}
}
}
<!-- For more information on using web.config transformation visit http://go.microsoft.com/fwlink/?LinkId=125889 -->
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<!--
In the example below, the "SetAttributes" transform will change the value of
"connectionString" to use "ReleaseSQLServer" only when the "Match" locator
finds an attribute "name" that has a value of "MyDB".
<connectionStrings>
<add name="MyDB"
connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True"
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
</connectionStrings>
-->
<system.web>
<!--
In the example below, the "Replace" transform will replace the entire
<customErrors> section of your web.config file.
Note that because there is only one customErrors section under the
<system.web> node, there is no need to use the "xdt:Locator" attribute.
<customErrors defaultRedirect="GenericError.htm"
mode="RemoteOnly" xdt:Transform="Replace">
<error statusCode="500" redirect="InternalError.htm"/>
</customErrors>
-->
</system.web>
</configuration>
\ No newline at end of file
<!-- For more information on using web.config transformation visit http://go.microsoft.com/fwlink/?LinkId=125889 -->
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<!--
In the example below, the "SetAttributes" transform will change the value of
"connectionString" to use "ReleaseSQLServer" only when the "Match" locator
finds an attribute "name" that has a value of "MyDB".
<connectionStrings>
<add name="MyDB"
connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True"
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
</connectionStrings>
-->
<system.web>
<compilation xdt:Transform="RemoveAttributes(debug)" />
<!--
In the example below, the "Replace" transform will replace the entire
<customErrors> section of your web.config file.
Note that because there is only one customErrors section under the
<system.web> node, there is no need to use the "xdt:Locator" attribute.
<customErrors defaultRedirect="GenericError.htm"
mode="RemoteOnly" xdt:Transform="Replace">
<error statusCode="500" redirect="InternalError.htm"/>
</customErrors>
-->
</system.web>
</configuration>
\ No newline at end of file
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<system.diagnostics>
<trace>
<listeners>
<add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=2.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
name="AzureDiagnostics">
<filter type="" />
</add>
</listeners>
</trace>
</system.diagnostics>
<!--
For a description of web.config changes see http://go.microsoft.com/fwlink/?LinkId=235367.
The following attributes can be set on the <httpRuntime> tag.
<system.Web>
<httpRuntime targetFramework="4.5.1" />
</system.Web>
-->
<system.web>
<compilation debug="true" targetFramework="4.5.1"/>
<httpRuntime targetFramework="4.5.1"/>
</system.web>
<system.webServer>
<security>
<requestFiltering>
<verbs allowUnlisted="true" />
</requestFiltering>
</security>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true">
<remove name="FileAuthorization" />
<remove name="WebDAVModule" />
</modules>
<handlers accessPolicy="Read, Write, Execute, Script">
<remove name="SimpleHandlerFactory-Integrated-4.0" />
<add name="SimpleHandlerFactory-Integrated-4.0" path="*.ashx" verb="*" type="System.Web.UI.SimpleHandlerFactory" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
<security>
<authorization>
<remove users="*" roles="" verbs="" />
<add accessType="Allow" users="*" verbs="*" />
</authorization>
</security>
</system.webServer>
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701"/>
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+"/>
</compilers>
</system.codedom>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
</configuration>
\ No newline at end of file
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.WindowsAzure;
using Microsoft.WindowsAzure.Diagnostics;
using Microsoft.WindowsAzure.ServiceRuntime;
namespace WebServer
{
public class WebRole : RoleEntryPoint
{
public override bool OnStart()
{
// For information on handling configuration changes
// see the MSDN topic at https://go.microsoft.com/fwlink/?LinkId=166357.
return base.OnStart();
}
}
}
<Project DefaultTargets="Build">
<Import Project="..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props" Condition="Exists('..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" />
<Import Project="..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props" Condition="Exists('..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props')" />
<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>
<ProductVersion>
</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>WebServer</RootNamespace>
<AssemblyName>WebServer</AssemblyName>
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
<UseIISExpress>true</UseIISExpress>
<IISExpressSSLPort />
<IISExpressAnonymousAuthentication />
<IISExpressWindowsAuthentication />
<IISExpressUseClassicPipelineMode />
<UseGlobalApplicationHostFile />
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<OutputPath>bin\</OutputPath>
<TargetFrameworkProfile />
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="Microsoft.Data.Edm, Version=5.8.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Data.Edm.5.8.4\lib\net40\Microsoft.Data.Edm.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Data.OData, Version=5.8.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Data.OData.5.8.4\lib\net40\Microsoft.Data.OData.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Data.Services.Client, Version=5.8.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Data.Services.Client.5.8.4\lib\net40\Microsoft.Data.Services.Client.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.WindowsAzure.ConfigurationManager.2.0.3\lib\net40\Microsoft.WindowsAzure.Configuration.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Diagnostics, Version=2.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.WindowsAzure.ServiceRuntime, Version=2.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Storage, Version=4.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\WindowsAzure.Storage.4.3.0\lib\net40\Microsoft.WindowsAzure.Storage.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.5.0.8\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Configuration" />
<Reference Include="System.Data" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Drawing" />
<Reference Include="System.EnterpriseServices" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Spatial, Version=5.8.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\System.Spatial.5.8.4\lib\net40\System.Spatial.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Web" />
<Reference Include="System.Web.ApplicationServices" />
<Reference Include="System.Web.DynamicData" />
<Reference Include="System.Web.Entity" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Web.Services" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
</ItemGroup>
<ItemGroup>
<Content Include="index.html" />
<Content Include="packages.config" />
<Content Include="WebSocket\Default.htm" />
<Content Include="Deflate.ashx" />
<Content Include="Echo.ashx" />
<Content Include="EmptyContent.ashx" />
<Content Include="GZip.ashx" />
<Content Include="Redirect.ashx" />
<Content Include="StatusCode.ashx" />
<Content Include="Test.ashx" />
<Content Include="VerifyUpload.ashx" />
<None Include="Properties\PublishProfiles\IIS_PublishToLocalPath_CHK.pubxml" />
<None Include="Properties\PublishProfiles\IIS_PublishToLocalPath_RET.pubxml" />
<None Include="Web.Debug.config">
<DependentUpon>Web.config</DependentUpon>
</None>
<None Include="Web.Release.config">
<DependentUpon>Web.config</DependentUpon>
</None>
<Content Include="WebSocket\EchoWebSocket.ashx" />
<Content Include="WebSocket\EchoWebSocketHeaders.ashx" />
</ItemGroup>
<ItemGroup>
<Content Include="Web.config">
<SubType>Designer</SubType>
</Content>
</ItemGroup>
<ItemGroup>
<Compile Include="AuthenticationHelper.cs" />
<Compile Include="ContentHelper.cs" />
<Compile Include="Deflate.ashx.cs">
<DependentUpon>Deflate.ashx</DependentUpon>
</Compile>
<Compile Include="Echo.ashx.cs">
<DependentUpon>Echo.ashx</DependentUpon>
</Compile>
<Compile Include="EmptyContent.ashx.cs">
<DependentUpon>EmptyContent.ashx</DependentUpon>
</Compile>
<Compile Include="GZip.ashx.cs">
<DependentUpon>GZip.ashx</DependentUpon>
</Compile>
<Compile Include="NameValueCollectionConverter.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Redirect.ashx.cs">
<DependentUpon>Redirect.ashx</DependentUpon>
</Compile>
<Compile Include="RequestHelper.cs" />
<Compile Include="RequestInformation.cs" />
<Compile Include="StatusCode.ashx.cs">
<DependentUpon>StatusCode.ashx</DependentUpon>
</Compile>
<Compile Include="Test.ashx.cs">
<DependentUpon>Test.ashx</DependentUpon>
</Compile>
<Compile Include="VerifyUpload.ashx.cs">
<DependentUpon>VerifyUpload.ashx</DependentUpon>
</Compile>
<Compile Include="WebRole.cs" />
<Compile Include="WebSocket\EchoWebSocket.ashx.cs">
<DependentUpon>EchoWebSocket.ashx</DependentUpon>
</Compile>
<Compile Include="WebSocket\EchoWebSocketHeaders.ashx.cs">
<DependentUpon>EchoWebSocketHeaders.ashx</DependentUpon>
</Compile>
</ItemGroup>
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != '' And Exists('$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets')" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
<ProjectExtensions>
<VisualStudio>
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
<WebProjectProperties>
<UseIIS>True</UseIIS>
<AutoAssignPort>True</AutoAssignPort>
<DevelopmentServerPort>42127</DevelopmentServerPort>
<DevelopmentServerVPath>/</DevelopmentServerVPath>
<IISUrl>http://localhost:42127/</IISUrl>
<NTLMAuthentication>False</NTLMAuthentication>
<UseCustomServer>False</UseCustomServer>
<CustomServerUrl>
</CustomServerUrl>
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
</WebProjectProperties>
</FlavorProperties>
</VisualStudio>
</ProjectExtensions>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props'))" />
</Target>
<!-- 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>
-->
<Target Name="AnnotateProjectsWithConfiguration" />
<Target Name="FindBestConfiguration" />
</Project>
<html>
<head>
<meta http-equiv="refresh" content="5; url=http://websocket.org/echo.html" />
</head>
<body>
<h3>Redirecting to the websocket.org test client in 5 seconds...</h3>
<p>Use the following URIs to test the local endpoint:</p>
<pre>
ws://testserver.contoso.com/WebSocket/EchoWebSocket.ashx
wss://testserver.contoso.com/WebSocket/EchoWebSocket.ashx
</pre>
</body>
</html>
<%@ WebHandler Language="C#" CodeBehind="EchoWebSocket.ashx.cs" Class="WebServer.EchoWebSocket" %>
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Net.WebSockets;
using System.Web;
using System.Web.WebSockets;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace WebServer
{
public class EchoWebSocket : IHttpHandler
{
private const int MaxBufferSize = 128 * 1024;
private bool _replyWithPartialMessages = false;
public void ProcessRequest(HttpContext context)
{
_replyWithPartialMessages = context.Request.Url.Query.Contains("replyWithPartialMessages");
string subProtocol = context.Request.QueryString["subprotocol"];
if (context.Request.Url.Query.Contains("delay10sec"))
{
Thread.Sleep(10000);
}
try
{
if (!context.IsWebSocketRequest)
{
context.Response.StatusCode = 200;
context.Response.ContentType = "text/plain";
context.Response.Write("Not a websocket request");
return;
}
if (!string.IsNullOrEmpty(subProtocol))
{
var wsOptions = new AspNetWebSocketOptions();
wsOptions.SubProtocol = subProtocol;
context.AcceptWebSocketRequest(ProcessWebSocketRequest, wsOptions);
}
else
{
context.AcceptWebSocketRequest(ProcessWebSocketRequest);
}
}
catch (Exception ex)
{
context.Response.StatusCode = 500;
context.Response.StatusDescription = ex.Message;
}
}
public bool IsReusable
{
get
{
return false;
}
}
private async Task ProcessWebSocketRequest(WebSocketContext wsContext)
{
WebSocket socket = wsContext.WebSocket;
var receiveBuffer = new byte[MaxBufferSize];
var throwAwayBuffer = new byte[MaxBufferSize];
// Stay in loop while websocket is open
while (socket.State == WebSocketState.Open || socket.State == WebSocketState.CloseSent)
{
var receiveResult = await socket.ReceiveAsync(new ArraySegment<byte>(receiveBuffer), CancellationToken.None);
if (receiveResult.MessageType == WebSocketMessageType.Close)
{
if (receiveResult.CloseStatus == WebSocketCloseStatus.Empty)
{
await socket.CloseAsync(WebSocketCloseStatus.Empty, null, CancellationToken.None);
}
else
{
await socket.CloseAsync(
receiveResult.CloseStatus.GetValueOrDefault(),
receiveResult.CloseStatusDescription,
CancellationToken.None);
}
continue;
}
// Keep reading until we get an entire message.
int offset = receiveResult.Count;
while (receiveResult.EndOfMessage == false)
{
if (offset < MaxBufferSize)
{
receiveResult = await socket.ReceiveAsync(
new ArraySegment<byte>(receiveBuffer, offset, MaxBufferSize - offset),
CancellationToken.None);
}
else
{
receiveResult = await socket.ReceiveAsync(
new ArraySegment<byte>(throwAwayBuffer),
CancellationToken.None);
}
offset += receiveResult.Count;
}
// Close socket if the message was too big.
if (offset > MaxBufferSize)
{
await socket.CloseAsync(
WebSocketCloseStatus.MessageTooBig,
string.Format("{0}: {1} > {2}", WebSocketCloseStatus.MessageTooBig.ToString(), offset, MaxBufferSize),
CancellationToken.None);
continue;
}
bool sendMessage = false;
if (receiveResult.MessageType == WebSocketMessageType.Text)
{
string receivedMessage = Encoding.UTF8.GetString(receiveBuffer, 0, offset);
if (receivedMessage == ".close")
{
await socket.CloseAsync(WebSocketCloseStatus.NormalClosure, receivedMessage, CancellationToken.None);
}
if (receivedMessage == ".shutdown")
{
await socket.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, receivedMessage, CancellationToken.None);
}
else if (receivedMessage == ".abort")
{
socket.Abort();
}
else if (receivedMessage == ".delay5sec")
{
await Task.Delay(5000);
}
else if (socket.State == WebSocketState.Open)
{
sendMessage = true;
}
}
else
{
sendMessage = true;
}
if (sendMessage)
{
await socket.SendAsync(
new ArraySegment<byte>(receiveBuffer, 0, offset),
receiveResult.MessageType,
!_replyWithPartialMessages,
CancellationToken.None);
}
}
}
}
}
<%@ WebHandler Language="C#" CodeBehind="EchoWebSocketHeaders.ashx.cs" Class="WebServer.EchoWebSocketHeaders" %>
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Web;
using System.Net.WebSockets;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace WebServer
{
public class EchoWebSocketHeaders : IHttpHandler
{
private const int MaxBufferSize = 1024;
public void ProcessRequest(HttpContext context)
{
try
{
if (!context.IsWebSocketRequest)
{
context.Response.StatusCode = 200;
context.Response.ContentType = "text/plain";
context.Response.Write("Not a websocket request");
return;
}
context.AcceptWebSocketRequest(ProcessWebSocketRequest);
}
catch (Exception ex)
{
context.Response.StatusCode = 500;
context.Response.StatusDescription = ex.Message;
}
}
public bool IsReusable
{
get
{
return false;
}
}
private async Task ProcessWebSocketRequest(WebSocketContext wsContext)
{
WebSocket socket = wsContext.WebSocket;
var receiveBuffer = new byte[MaxBufferSize];
// Reflect all headers and cookies
var sb = new StringBuilder();
sb.AppendLine("Headers:");
foreach (string header in wsContext.Headers.AllKeys)
{
sb.Append(header);
sb.Append(":");
sb.AppendLine(wsContext.Headers[header]);
}
byte[] sendBuffer = Encoding.UTF8.GetBytes(sb.ToString());
await socket.SendAsync(new ArraySegment<byte>(sendBuffer), WebSocketMessageType.Text, true, new CancellationToken());
// Stay in loop while websocket is open
while (socket.State == WebSocketState.Open || socket.State == WebSocketState.CloseSent)
{
var receiveResult = await socket.ReceiveAsync(new ArraySegment<byte>(receiveBuffer), CancellationToken.None);
if (receiveResult.MessageType == WebSocketMessageType.Close)
{
if (receiveResult.CloseStatus == WebSocketCloseStatus.Empty)
{
await socket.CloseAsync(WebSocketCloseStatus.Empty, null, CancellationToken.None);
}
else
{
await socket.CloseAsync(
receiveResult.CloseStatus.GetValueOrDefault(),
receiveResult.CloseStatusDescription,
CancellationToken.None);
}
continue;
}
}
}
}
}
<!DOCTYPE html>
<html>
<head>
<title>Networking Test Server</title>
<meta charset="utf-8" />
</head>
<body>
<h1>NetworkingTestServer</h1>
<p>Networking test server in Azure. Used by dotnet/corefx repo.</p>
</body>
</html>
<packages>
<package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="1.0.0" targetFramework="net452" />
<package id="Microsoft.Data.Edm" version="5.8.4" targetFramework="net452" />
<package id="Microsoft.Data.OData" version="5.8.4" targetFramework="net452" />
<package id="Microsoft.Data.Services.Client" version="5.8.4" targetFramework="net452" />
<package id="Microsoft.Net.Compilers" version="1.0.0" targetFramework="net452" developmentDependency="true" />
<package id="Microsoft.WindowsAzure.ConfigurationManager" version="2.0.3" targetFramework="net452" />
<package id="Newtonsoft.Json" version="5.0.8" targetFramework="net452" />
<package id="System.Spatial" version="5.8.4" targetFramework="net452" />
<package id="WindowsAzure.Storage" version="4.3.0" targetFramework="net452" />
</packages>
# Licensed to the .NET Foundation under one or more agreements.
# The .NET Foundation licenses this file to you under the MIT license.
# Requires Visual Studio Command Prompt
# Requires Azure SDK and .NET Framework SDK installed on the build machine.
$cdir = pwd
$folderName = "CoreFxNetCloudService"
$src = Join-Path $cdir $folderName
$tmp = Join-Path $Env:TEMP $folderName
$tmpOut = Join-Path $tmp "WebServer\PublishToIIS"
$dst = Join-Path $cdir "..\Deployment\IISApplications"
$nugetSrc = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe"
if (Test-Path $tmp)
{
rm -Recurse $tmp
}
copy -Recurse $src $Env:TEMP
Start-BitsTransfer -Source $nugetSrc -Destination $tmp
cd $tmp
.\nuget restore
msbuild /p:DeployOnBuild=true /p:PublishProfile=IIS_PublishToLocalPath_RET
copy -Recurse $tmpOut $dst
cd $cdir
rm -Recurse $tmp
......@@ -17,7 +17,6 @@
<PackageReference Include="System.Reflection.Metadata" Version="$(SystemReflectionMetadataVersion)" PrivateAssets="All" />
<!-- These versions should not be newer than what Visual Studio MSBuild uses -->
<PackageReference Include="System.Threading.Tasks.Extensions" Version="$(SystemThreadingTasksExtensionsVersion)" PrivateAssets="all" />
<PackageReference Include="System.Text.Json" Version="5.0.0" PrivateAssets="all" />
</ItemGroup>
<ItemGroup>
......
......@@ -20,12 +20,6 @@
<PackageReference Include="Microsoft.Build" Version="$(MicrosoftBuildVersion)" />
<PackageReference Include="Microsoft.Build.Tasks.Core" Version="$(MicrosoftBuildTasksCoreVersion)" />
<PackageReference Include="System.Reflection.MetadataLoadContext" Version="$(SystemReflectionMetadataLoadContextVersion)" />
<!-- When we requested a version that is newer than what comes with Visual Studio version of msbuild, it causes problems with
running the task from inside VS. Therefore, we are using the moving version only for source-build. -->
<PackageReference Include="System.Text.Json" Condition="'$(DotNetBuildFromSource)' != 'true'" Version="6.0.0" PrivateAssets="all" />
<PackageReference Include="System.Text.Json" Condition="'$(DotNetBuildFromSource)' == 'true'" Version="$(SystemTextJsonVersion)" PrivateAssets="all" />
</ItemGroup>
<Target Name="GetFilesToPackage" Returns="@(FilesToPackage)">
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册