1
0
Форкнуть 0
This commit is contained in:
Anastasia Baranchenkova 2015-04-17 14:17:53 -07:00
Родитель 32ce48d42b b53688ada9
Коммит 6bf608c001
47 изменённых файлов: 301 добавлений и 471 удалений

2
.gitignore поставляемый
Просмотреть файл

@ -24,3 +24,5 @@ nuget.exe
*.ipch
bower_components/
node_modules/
.vs/
project.lock.json

Просмотреть файл

@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.22609.0
VisualStudioVersion = 14.0.22809.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{2E6DDE9E-8C75-4F9C-8906-08EBDD6E73EF}"
EndProject
@ -12,15 +12,15 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
Readme.md = Readme.md
EndProjectSection
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "ApplicationInsights.AspNet", "src\ApplicationInsights.AspNet\ApplicationInsights.AspNet.kproj", "{95EC3635-22E4-4C3A-A066-F5823A0648DA}"
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.ApplicationInsights.AspNet", "src\Microsoft.ApplicationInsights.AspNet\Microsoft.ApplicationInsights.AspNet.xproj", "{95EC3635-22E4-4C3A-A066-F5823A0648DA}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{8B5230E5-8138-44D6-839F-DF9248F195EE}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "ApplicationInsights.AspNet.UnitTests", "test\ApplicationInsights.AspNet.Tests\ApplicationInsights.AspNet.UnitTests.kproj", "{2766D8AF-C20B-4F3A-8260-6C2D39B7A8A0}"
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.ApplicationInsights.AspNet.Tests", "test\Microsoft.ApplicationInsights.AspNet.Tests\Microsoft.ApplicationInsights.AspNet.Tests.xproj", "{2766D8AF-C20B-4F3A-8260-6C2D39B7A8A0}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "SampleWebAppIntegration", "test\SampleWebAppIntegration\SampleWebAppIntegration.kproj", "{330152EC-1092-41F0-9F96-C3438E07FCC2}"
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "SampleWebAppIntegration", "test\SampleWebAppIntegration\SampleWebAppIntegration.xproj", "{330152EC-1092-41F0-9F96-C3438E07FCC2}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "FunctionalTestUtils", "test\FunctionalTestUtils\FunctionalTestUtils.kproj", "{B7217A00-66FA-49A8-8EF3-39C07E1F7E33}"
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "FunctionalTestUtils", "test\FunctionalTestUtils\FunctionalTestUtils.xproj", "{B7217A00-66FA-49A8-8EF3-39C07E1F7E33}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution

Просмотреть файл

@ -82,9 +82,8 @@ Developing
----------
1. Repository (private now): https://github.com/microsoft/AppInsights-aspnetv5
2. Asp.Net information: https://github.com/aspnet/home
3. VS 2015 installation:
- *(recommended by [Anastasia](https://github.com/abaranch))*: http://blogs.msdn.com/b/visualstudioalm/archive/2014/06/04/visual-studio-14-ctp-now-available-in-the-virtual-machine-azure-gallery.aspx
- You can just install it on your machine: https://www.visualstudio.com/en-us/news/vs2015-vs.aspx
3. Install VS 2015 RC.
Running and writing tests
-------------------------
@ -106,9 +105,7 @@ Add dependencies to project.json:
```
"FunctionalTestUtils": "1.0.0-*",
"xunit": "2.1.0.0-beta1-build2945",
"xunit.runner.aspnet": "2.1.0.0-beta1-build60",
"xunit.runner.visualstudio": "2.1.0.0-beta1-build1051"
"xunit.runner.aspnet": "2.0.0-aspnet-beta5-*",
```
and test command:
@ -122,3 +119,10 @@ Add this initialization logic to Startup.cs:
```
services.AddFunctionalTestTelemetryChannel();
```
*Running Tests*
Open a developer command prompt, navigate to project folder and run:
```
dnx . test
```

Просмотреть файл

@ -1,6 +1,6 @@
{
"sources": [ "src", "test" ],
"sdk": {
"version": "1.0.0-beta3"
"version": "1.0.0-beta4"
}
}

Просмотреть файл

@ -1,25 +0,0 @@
{
"version": "0.30.0.1-beta",
"dependencies": {
"Microsoft.AspNet.Hosting": "1.0.0-beta3",
"Microsoft.Framework.Logging": "1.0.0-beta3",
"Microsoft.AspNet.Http.Extensions": "1.0.0-beta3",
"Microsoft.AspNet.RequestContainer": "1.0.0-beta3",
"Microsoft.AspNet.Mvc.Core": "6.0.0-beta3",
"System.Net.NameResolution": "4.0.0-beta-*"
},
"frameworks": {
"aspnet50": {
"dependencies": {
"Microsoft.ApplicationInsights": "0.13.4-build00460"
}
},
"aspnetcore50": {
"dependencies": {
"System.Runtime": "4.0.20-*",
"Microsoft.ApplicationInsights.Portable": "0.30.0.0-beta"
}
}
}
}

Просмотреть файл

@ -17,7 +17,7 @@
public static IApplicationBuilder UseApplicationInsightsRequestTelemetry(this IApplicationBuilder app)
{
// TODO: Register if customer did not register
app.UseRequestServices();
//app.UseRequestServices();
app.UseMiddleware<ApplicationInsightsRequestMiddleware>();
return app;

Просмотреть файл

@ -4,7 +4,6 @@
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(VSToolsPath)\AspNet\Microsoft.Web.AspNet.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>95ec3635-22e4-4c3a-a066-f5823a0648da</ProjectGuid>
<RootNamespace>Microsoft.ApplicationInsights.AspNet</RootNamespace>
@ -20,8 +19,6 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<ProduceOutputsOnBuild>True</ProduceOutputsOnBuild>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<ProduceOutputsOnBuild>True</ProduceOutputsOnBuild>
</PropertyGroup>
<Import Project="$(VSToolsPath)\AspNet\Microsoft.Web.AspNet.targets" Condition="'$(VSToolsPath)' != ''" />
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" />
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" />
</Project>

Просмотреть файл

@ -4,7 +4,6 @@
using Microsoft.ApplicationInsights.Channel;
using Microsoft.ApplicationInsights.DataContracts;
using Microsoft.AspNet.Http;
using Microsoft.AspNet.Http.Interfaces;
using System.Collections.Generic;
using System.Net.Sockets;
using System.Net;

Просмотреть файл

@ -27,7 +27,7 @@
{
try
{
var context = this.httpContextAccessor.Value;
var context = this.httpContextAccessor.HttpContext;
if (context == null)
{

Просмотреть файл

@ -4,7 +4,6 @@
using Microsoft.ApplicationInsights.DataContracts;
using Microsoft.AspNet.Hosting;
using Microsoft.AspNet.Http;
using Microsoft.AspNet.Http.Core;
using Microsoft.Net.Http.Headers;
using System;

Просмотреть файл

@ -50,7 +50,7 @@
if (userCookieParts.Length >= 2)
{
// todo: add tracing
DateTimeOffset acquisitionDate;
DateTimeOffset acquisitionDate = DateTimeOffset.MinValue;
if (!string.IsNullOrEmpty(userCookieParts[1])
&& DateTimeOffset.TryParse(userCookieParts[1], CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal, out acquisitionDate))
{

Просмотреть файл

@ -0,0 +1,47 @@
{
"description": "Application Insights for ASP.NET 5 web applications. See http://go.microsoft.com/fwlink/?LinkID=510752 for more information.",
"authors": [ "Microsoft" ],
"version": "1.0.0-*",
"projectUrl": "https://github.com/Microsoft/AppInsights-aspnetv5",
"tags": [ "Analytics", "ApplicationInsights", "Telemetry", "AppInsights" ],
/* TODO: Include and verify additional properties after upgrading to VS2015 RC and beta 5.
* For details, see:
* https://github.com/aspnet/dnx/issues/1302
* https://github.com/aspnet/dnx/blob/dev/src/Microsoft.Framework.PackageManager/Building/BuildManager.cs#L237
"title": "Application Insights for ASP.NET 5 Web Applications",
"copyright": "Copyright © Microsoft. All Rights Reserved.",
"iconUrl": "http://appanacdn.blob.core.windows.net/cdn/icons/aic.png",
"licenseUrl": "http://go.microsoft.com/fwlink/?LinkID=510709",
"requireLicenseAcceptance": true,
* Do we need these?
"summary": "Application Insights for ASP.NET 5 Web Applications",
"owners": ["AppInsightsSdk"],
*/
"dependencies": {
"Microsoft.AspNet.Hosting": "1.0.0-beta5-*",
"Microsoft.Framework.Logging": "1.0.0-beta5-*",
"Microsoft.AspNet.Http": "1.0.0-beta5-*",
"Microsoft.AspNet.Http.Extensions": "1.0.0-beta5-*",
"Microsoft.AspNet.Mvc.Core": "6.0.0-beta5-*",
"System.Net.NameResolution": "4.0.0-beta-*"
},
"frameworks": {
"dnx451": {
"dependencies": {
"Microsoft.ApplicationInsights": "0.13.4-build00460"
}
},
"dnxcore50": {
"dependencies": {
"System.Collections": "4.0.10-beta-22807",
"System.Linq": "4.0.0-beta-22807",
"System.Threading": "4.0.10-beta-22807",
"Microsoft.CSharp": "4.0.0-beta-22807",
"Microsoft.ApplicationInsights.Portable": "0.30.0.0-beta"
}
}
}
}

Просмотреть файл

@ -1,23 +0,0 @@
{
"dependencies": {
"ApplicationInsights.AspNet": "0.30.0.1-beta",
"xunit": "2.1.0.0-beta1-build2945",
"xunit.runner.aspnet": "2.1.0.0-beta1-build60",
"xunit.runner.visualstudio": "2.1.0.0-beta1-build1051",
"Microsoft.AspNet.FeatureModel": "1.0.0-beta3",
"Microsoft.AspNet.Http.Extensions": "1.0.0-beta3",
"Microsoft.AspNet.Hosting": "1.0.0-beta3",
"Microsoft.Framework.Logging": "1.0.0-beta3",
"Microsoft.AspNet.Http.Extensions": "1.0.0-beta3",
"Microsoft.AspNet.RequestContainer": "1.0.0-beta3",
"Microsoft.AspNet.Mvc.Core": "6.0.0-beta3",
"Microsoft.Framework.ConfigurationModel.Json": "1.0.0-beta3"
},
"commands": {
"test": "xunit.runner.aspnet"
},
"frameworks": {
"aspnet50": { },
"aspnetcore50": { }
}
}

Просмотреть файл

@ -4,17 +4,15 @@
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(VSToolsPath)\AspNet\Microsoft.Web.AspNet.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>b7217a00-66fa-49a8-8ef3-39c07e1f7e33</ProjectGuid>
<RootNamespace>FunctionalTestUtils</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\artifacts\bin\$(MSBuildProjectName)\</OutputPath>
</PropertyGroup>
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<Import Project="$(VSToolsPath)\AspNet\Microsoft.Web.AspNet.targets" Condition="'$(VSToolsPath)' != ''" />
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" />
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" />
</Project>

Просмотреть файл

@ -3,7 +3,7 @@
using Microsoft.AspNet.Hosting;
using Microsoft.Framework.ConfigurationModel;
using Microsoft.Framework.DependencyInjection;
using Microsoft.Framework.DependencyInjection.Fallback;
using Microsoft.Framework.Runtime;
using System;
public class InProcessServer : IDisposable
@ -31,25 +31,11 @@
var config = new Configuration();
config.Add(customConfig);
var serviceCollection = HostingServices.Create(null);
var services = serviceCollection.BuildServiceProvider();
var context = new HostingContext()
{
Services = services,
Configuration = config,
ServerName = "Microsoft.AspNet.Server.WebListener",
ApplicationName = assemblyName,
EnvironmentName = "Production"
};
var hostingEngine = services.GetService<IHostingEngine>();
if (hostingEngine == null)
{
throw new Exception("TODO: IHostingEngine service not available exception");
}
this.hostingEngine = hostingEngine.Start(context);
var engine = WebHost.CreateEngine(null, config)
.UseEnvironment("Production")
.UseServer("Microsoft.AspNet.Server.WebListener")
.UseStartup(assemblyName);
this.hostingEngine = engine.Start();
}
public void Dispose()

Просмотреть файл

@ -1,10 +1,10 @@
{
"version": "1.0.0-*",
"dependencies": {
"Microsoft.AspNet.Diagnostics": "1.0.0-beta3",
"Microsoft.AspNet.Hosting": "1.0.0-beta3",
"Microsoft.AspNet.Mvc": "6.0.0-beta3",
"Microsoft.AspNet.Server.WebListener": "1.0.0-beta3",
"Microsoft.AspNet.Diagnostics": "1.0.0-beta5-*",
"Microsoft.AspNet.Hosting": "1.0.0-beta5-*",
"Microsoft.AspNet.Mvc": "6.0.0-beta5-*",
"Microsoft.AspNet.Server.WebListener": "1.0.0-beta5-*",
"xunit": "2.1.0.0-beta1-build2945",
"xunit.runner.aspnet": "2.1.0.0-beta1-build60",
"xunit.runner.visualstudio": "2.1.0.0-beta1-build1051",
@ -12,14 +12,17 @@
},
"frameworks": {
"aspnet50": {
"dnx451": {
"dependencies": {
"Microsoft.ApplicationInsights": "0.13.4-build00460"
}
},
"aspnetcore50": {
"dnxcore50": {
"dependencies": {
"System.Runtime": "4.0.20-beta-22523",
"System.Collections": "4.0.10-beta-22807",
"System.Linq": "4.0.0-beta-22807",
"System.Threading": "4.0.10-beta-22807",
"Microsoft.CSharp": "4.0.0-beta-22807",
"Microsoft.ApplicationInsights.Portable": "0.30.0.0-beta"
}
}

Просмотреть файл

@ -12,11 +12,18 @@
using Microsoft.AspNet.Hosting;
using Microsoft.Framework.ConfigurationModel;
using Microsoft.Framework.DependencyInjection;
using Microsoft.Framework.DependencyInjection.Fallback;
using Xunit;
public static class ApplicationInsightsExtensionsTests
{
public static ServiceCollection GetServiceCollectionWithContextAccessor()
{
var services = new ServiceCollection();
IHttpContextAccessor contextAccessor = new HttpContextAccessor();
services.AddInstance<IHttpContextAccessor>(contextAccessor);
return services;
}
public static class SetApplicationInsightsTelemetryDeveloperMode
{
[Fact]
@ -24,7 +31,7 @@
{
var telemetryChannel = new FakeTelemetryChannel();
var telemetryConfiguration = new TelemetryConfiguration { TelemetryChannel = telemetryChannel };
var services = new ServiceCollection();
var services = ApplicationInsightsExtensionsTests.GetServiceCollectionWithContextAccessor();
services.AddInstance(telemetryConfiguration);
var app = new ApplicationBuilder(services.BuildServiceProvider());
@ -37,29 +44,29 @@
public static class AddApplicationInsightsTelemetry
{
[Theory]
[InlineData(typeof(IContextInitializer), typeof(DomainNameRoleInstanceContextInitializer), LifecycleKind.Singleton)]
[InlineData(typeof(ITelemetryInitializer), typeof(ClientIpHeaderTelemetryInitializer), LifecycleKind.Singleton)]
[InlineData(typeof(ITelemetryInitializer), typeof(OperationNameTelemetryInitializer), LifecycleKind.Singleton)]
[InlineData(typeof(ITelemetryInitializer), typeof(OperationIdTelemetryInitializer), LifecycleKind.Singleton)]
[InlineData(typeof(ITelemetryInitializer), typeof(UserAgentTelemetryInitializer), LifecycleKind.Singleton)]
[InlineData(typeof(ITelemetryInitializer), typeof(WebSessionTelemetryInitializer), LifecycleKind.Singleton)]
[InlineData(typeof(ITelemetryInitializer), typeof(WebUserTelemetryInitializer), LifecycleKind.Singleton)]
[InlineData(typeof(TelemetryConfiguration), null, LifecycleKind.Singleton)]
[InlineData(typeof(TelemetryClient), typeof(TelemetryClient), LifecycleKind.Scoped)]
public static void RegistersExpectedServices(Type serviceType, Type implementationType, LifecycleKind lifecycle)
[InlineData(typeof(IContextInitializer), typeof(DomainNameRoleInstanceContextInitializer), ServiceLifetime.Singleton)]
[InlineData(typeof(ITelemetryInitializer), typeof(ClientIpHeaderTelemetryInitializer), ServiceLifetime.Singleton)]
[InlineData(typeof(ITelemetryInitializer), typeof(OperationNameTelemetryInitializer), ServiceLifetime.Singleton)]
[InlineData(typeof(ITelemetryInitializer), typeof(OperationIdTelemetryInitializer), ServiceLifetime.Singleton)]
[InlineData(typeof(ITelemetryInitializer), typeof(UserAgentTelemetryInitializer), ServiceLifetime.Singleton)]
[InlineData(typeof(ITelemetryInitializer), typeof(WebSessionTelemetryInitializer), ServiceLifetime.Singleton)]
[InlineData(typeof(ITelemetryInitializer), typeof(WebUserTelemetryInitializer), ServiceLifetime.Singleton)]
[InlineData(typeof(TelemetryConfiguration), null, ServiceLifetime.Singleton)]
[InlineData(typeof(TelemetryClient), typeof(TelemetryClient), ServiceLifetime.Scoped)]
public static void RegistersExpectedServices(Type serviceType, Type implementationType, ServiceLifetime lifecycle)
{
var services = new ServiceCollection();
var services = ApplicationInsightsExtensionsTests.GetServiceCollectionWithContextAccessor();
services.AddApplicationInsightsTelemetry(new Configuration());
IServiceDescriptor service = services.Single(s => s.ServiceType == serviceType && s.ImplementationType == implementationType);
Assert.Equal(lifecycle, service.Lifecycle);
ServiceDescriptor service = services.Single(s => s.ServiceType == serviceType && s.ImplementationType == implementationType);
Assert.Equal(lifecycle, service.Lifetime);
}
[Fact]
public static void DoesNotThrowWithoutInstrumentationKey()
{
var services = new ServiceCollection();
var services = ApplicationInsightsExtensionsTests.GetServiceCollectionWithContextAccessor();
//Empty configuration that doesn't have instrumentation key
IConfiguration config = new Configuration();
@ -70,7 +77,7 @@
[Fact]
public static void RegistersTelemetryConfigurationFactoryMethodThatCreatesDefaultInstance()
{
IServiceCollection services = HostingServices.Create();
var services = ApplicationInsightsExtensionsTests.GetServiceCollectionWithContextAccessor();
services.AddApplicationInsightsTelemetry(new Configuration());
@ -82,8 +89,8 @@
[Fact]
public static void RegistersTelemetryConfigurationFactoryMethodThatReadsInstrumentationKeyFromConfiguration()
{
IServiceCollection services = HostingServices.Create();
var config = new Configuration().AddJsonFile("content\\config.json");
var services = ApplicationInsightsExtensionsTests.GetServiceCollectionWithContextAccessor();
var config = new Configuration(".").AddJsonFile("content\\config.json");
services.AddApplicationInsightsTelemetry(config);
@ -96,7 +103,7 @@
public static void RegistersTelemetryConfigurationFactoryMethodThatPopulatesItWithContextInitializersFromContainer()
{
var contextInitializer = new FakeContextInitializer();
IServiceCollection services = HostingServices.Create();
var services = ApplicationInsightsExtensionsTests.GetServiceCollectionWithContextAccessor();
services.AddInstance<IContextInitializer>(contextInitializer);
services.AddApplicationInsightsTelemetry(new Configuration());
@ -110,7 +117,7 @@
public static void RegistersTelemetryConfigurationFactoryMethodThatPopulatesItWithTelemetryInitializersFromContainer()
{
var telemetryInitializer = new FakeTelemetryInitializer();
IServiceCollection services = HostingServices.Create();
var services = ApplicationInsightsExtensionsTests.GetServiceCollectionWithContextAccessor();
services.AddInstance<ITelemetryInitializer>(telemetryInitializer);
services.AddApplicationInsightsTelemetry(new Configuration());
@ -124,7 +131,7 @@
public static void RegistersTelemetryConfigurationFactoryMethodThatPopulatesItWithTelemetryChannelFromContainer()
{
var telemetryChannel = new FakeTelemetryChannel();
IServiceCollection services = HostingServices.Create();
var services = ApplicationInsightsExtensionsTests.GetServiceCollectionWithContextAccessor();
services.AddInstance<ITelemetryChannel>(telemetryChannel);
services.AddApplicationInsightsTelemetry(new Configuration());
@ -137,7 +144,7 @@
[Fact]
public static void DoesNotOverrideDefaultTelemetryChannelIfTelemetryChannelServiceIsNotRegistered()
{
IServiceCollection services = HostingServices.Create();
var services = ApplicationInsightsExtensionsTests.GetServiceCollectionWithContextAccessor();
services.AddApplicationInsightsTelemetry(new Configuration());
@ -149,7 +156,7 @@
[Fact]
public static void RegistersTelemetryClientToGetTelemetryConfigurationFromContainerAndNotGlobalInstance()
{
IServiceCollection services = HostingServices.Create();
var services = ApplicationInsightsExtensionsTests.GetServiceCollectionWithContextAccessor();
services.AddApplicationInsightsTelemetry(new Configuration());

Просмотреть файл

@ -6,6 +6,9 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNet.Mvc.ModelBinding.Validation;
using Microsoft.Framework.Internal;
using Microsoft.Framework.WebEncoders;
internal class HtmlHelperMock : IHtmlHelper
{
@ -22,6 +25,14 @@
}
}
public IHtmlEncoder HtmlEncoder
{
get
{
throw new NotImplementedException();
}
}
public string IdAttributeDotReplacement
{
get
@ -35,6 +46,14 @@
}
}
public IJavaScriptStringEncoder JavaScriptStringEncoder
{
get
{
throw new NotImplementedException();
}
}
public IModelMetadataProvider MetadataProvider
{
get
@ -43,6 +62,22 @@
}
}
public ITempDataDictionary TempData
{
get
{
throw new NotImplementedException();
}
}
public IUrlEncoder UrlEncoder
{
get
{
throw new NotImplementedException();
}
}
public dynamic ViewBag
{
get
@ -142,7 +177,17 @@
throw new NotImplementedException();
}
public IEnumerable<ModelClientValidationRule> GetClientValidationRules(ModelMetadata metadata, string name)
public IEnumerable<ModelClientValidationRule> GetClientValidationRules(ModelExplorer modelExplorer, string expression)
{
throw new NotImplementedException();
}
public IEnumerable<SelectListItem> GetEnumSelectList(Type enumType)
{
throw new NotImplementedException();
}
public IEnumerable<SelectListItem> GetEnumSelectList<TEnum>() where TEnum : struct
{
throw new NotImplementedException();
}

Просмотреть файл

@ -4,7 +4,6 @@
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(VSToolsPath)\AspNet\Microsoft.Web.AspNet.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>2766d8af-c20b-4f3a-8260-6c2d39b7a8a0</ProjectGuid>
</PropertyGroup>
@ -24,5 +23,6 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<ProduceOutputsOnBuild>True</ProduceOutputsOnBuild>
</PropertyGroup>
<Import Project="$(VSToolsPath)\AspNet\Microsoft.Web.AspNet.targets" Condition="'$(VSToolsPath)' != ''" />
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" />
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" />
</Project>

Просмотреть файл

@ -4,7 +4,7 @@
using Microsoft.ApplicationInsights.AspNet.Tests.Helpers;
using Microsoft.ApplicationInsights.DataContracts;
using Microsoft.AspNet.Hosting;
using Microsoft.AspNet.Http.Core;
using Microsoft.AspNet.Http;
using System;
using System.Collections.Generic;
using Xunit;
@ -20,7 +20,7 @@
[Fact]
public void InitializeDoesNotThrowIfHttpContextIsUnavailable()
{
var ac = new HttpContextAccessor() { Value = null };
var ac = new HttpContextAccessor() { HttpContext = null };
var initializer = new ClientIpHeaderTelemetryInitializer(ac);
@ -30,7 +30,7 @@
[Fact]
public void InitializeDoesNotThrowIfRequestTelemetryIsUnavailable()
{
var ac = new HttpContextAccessor() { Value = new DefaultHttpContext() };
var ac = new HttpContextAccessor() { HttpContext = new DefaultHttpContext() };
var initializer = new ClientIpHeaderTelemetryInitializer(ac);
@ -40,10 +40,10 @@
[Fact]
public void InitializeSetsIPFromStandardHeader()
{
var ac = new HttpContextAccessor() { Value = new DefaultHttpContext() };
var ac = new HttpContextAccessor() { HttpContext = new DefaultHttpContext() };
var requestTelemetry = new RequestTelemetry();
ac.Value.Request.Headers.Add("X-Forwarded-For", new string[] { "127.0.0.3" });
ac.Value.RequestServices = new TestServiceProvider(new List<object>() { requestTelemetry });
ac.HttpContext.Request.Headers.Add("X-Forwarded-For", new string[] { "127.0.0.3" });
ac.HttpContext.RequestServices = new TestServiceProvider(new List<object>() { requestTelemetry });
var initializer = new ClientIpHeaderTelemetryInitializer(ac);
@ -55,10 +55,10 @@
[Fact]
public void InitializeSetsIPFromCustomHeader()
{
var ac = new HttpContextAccessor() { Value = new DefaultHttpContext() };
var ac = new HttpContextAccessor() { HttpContext = new DefaultHttpContext() };
var requestTelemetry = new RequestTelemetry();
ac.Value.Request.Headers.Add("HEADER", new string[] { "127.0.0.3;127.0.0.4" });
ac.Value.RequestServices = new TestServiceProvider(new List<object>() { requestTelemetry });
ac.HttpContext.Request.Headers.Add("HEADER", new string[] { "127.0.0.3;127.0.0.4" });
ac.HttpContext.RequestServices = new TestServiceProvider(new List<object>() { requestTelemetry });
var initializer = new ClientIpHeaderTelemetryInitializer(ac);
initializer.HeaderNames.Add("HEADER");
initializer.HeaderValueSeparators = ",;";
@ -73,9 +73,9 @@
{
var requestTelemetry = new RequestTelemetry();
requestTelemetry.Context.Location.Ip = "127.0.0.4";
var ac = new HttpContextAccessor() { Value = new DefaultHttpContext() };
ac.Value.Request.Headers.Add("X-Forwarded-For", new string[] { "127.0.0.3" });
ac.Value.RequestServices = new TestServiceProvider(new List<object>() { requestTelemetry });
var ac = new HttpContextAccessor() { HttpContext = new DefaultHttpContext() };
ac.HttpContext.Request.Headers.Add("X-Forwarded-For", new string[] { "127.0.0.3" });
ac.HttpContext.RequestServices = new TestServiceProvider(new List<object>() { requestTelemetry });
var initializer = new ClientIpHeaderTelemetryInitializer(ac);
initializer.Initialize(requestTelemetry);

Просмотреть файл

@ -4,7 +4,7 @@
using Microsoft.ApplicationInsights.AspNet.Tests.Helpers;
using Microsoft.ApplicationInsights.DataContracts;
using Microsoft.AspNet.Hosting;
using Microsoft.AspNet.Http.Core;
using Microsoft.AspNet.Http;
using System;
using System.Collections.Generic;
using Xunit;
@ -20,7 +20,7 @@
[Fact]
public void InitializeDoesNotThrowIfHttpContextIsUnavailable()
{
var ac = new HttpContextAccessor() { Value = null };
var ac = new HttpContextAccessor() { HttpContext = null };
var initializer = new OperationIdTelemetryInitializer(ac);
@ -30,7 +30,7 @@
[Fact]
public void InitializeDoesNotThrowIfRequestTelemetryIsUnavailable()
{
var ac = new HttpContextAccessor() { Value = new DefaultHttpContext() };
var ac = new HttpContextAccessor() { HttpContext = new DefaultHttpContext() };
var initializer = new OperationIdTelemetryInitializer(ac);
@ -42,8 +42,8 @@
{
var telemetry = new EventTelemetry();
telemetry.Context.Operation.Id = "123";
var ac = new HttpContextAccessor() { Value = new DefaultHttpContext() };
ac.Value.RequestServices = new TestServiceProvider(new List<object>() { new RequestTelemetry() });
var ac = new HttpContextAccessor() { HttpContext = new DefaultHttpContext() };
ac.HttpContext.RequestServices = new TestServiceProvider(new List<object>() { new RequestTelemetry() });
var initializer = new OperationIdTelemetryInitializer(ac);
initializer.Initialize(telemetry);
@ -56,8 +56,8 @@
{
var telemetry = new EventTelemetry();
var requestTelemetry = new RequestTelemetry();
var ac = new HttpContextAccessor() { Value = new DefaultHttpContext() };
ac.Value.RequestServices = new TestServiceProvider(new List<object>() { requestTelemetry });
var ac = new HttpContextAccessor() { HttpContext = new DefaultHttpContext() };
ac.HttpContext.RequestServices = new TestServiceProvider(new List<object>() { requestTelemetry });
var initializer = new OperationIdTelemetryInitializer(ac);
initializer.Initialize(telemetry);

Просмотреть файл

@ -4,7 +4,7 @@
using Microsoft.ApplicationInsights.AspNet.Tests.Helpers;
using Microsoft.ApplicationInsights.DataContracts;
using Microsoft.AspNet.Hosting;
using Microsoft.AspNet.Http.Core;
using Microsoft.AspNet.Http;
using System;
using System.Collections.Generic;
using Xunit;
@ -20,7 +20,7 @@
[Fact]
public void InitializeDoesNotThrowIfHttpContextIsUnavailable()
{
var ac = new HttpContextAccessor() { Value = null };
var ac = new HttpContextAccessor() { HttpContext = null };
var initializer = new OperationNameTelemetryInitializer(ac);
@ -30,7 +30,7 @@
[Fact]
public void InitializeDoesNotThrowIfRequestTelemetryIsUnavailable()
{
var ac = new HttpContextAccessor() { Value = new DefaultHttpContext() };
var ac = new HttpContextAccessor() { HttpContext = new DefaultHttpContext() };
var initializer = new OperationNameTelemetryInitializer(ac);
@ -42,8 +42,8 @@
{
var telemetry = new EventTelemetry();
telemetry.Context.Operation.Name = "Name";
var ac = new HttpContextAccessor() { Value = new DefaultHttpContext() };
ac.Value.RequestServices = new TestServiceProvider(new List<object>() { new RequestTelemetry() });
var ac = new HttpContextAccessor() { HttpContext = new DefaultHttpContext() };
ac.HttpContext.RequestServices = new TestServiceProvider(new List<object>() { new RequestTelemetry() });
var initializer = new OperationNameTelemetryInitializer(ac);
initializer.Initialize(telemetry);
@ -58,8 +58,8 @@
var request = new DefaultHttpContext().Request;
request.Method = "GET";
request.Path = new Microsoft.AspNet.Http.PathString("/Test");
var ac = new HttpContextAccessor() { Value = request.HttpContext };
ac.Value.RequestServices = new TestServiceProvider(new List<object>() { new RequestTelemetry() });
var ac = new HttpContextAccessor() { HttpContext = request.HttpContext };
ac.HttpContext.RequestServices = new TestServiceProvider(new List<object>() { new RequestTelemetry() });
var initializer = new OperationNameTelemetryInitializer(ac);
initializer.Initialize(telemetry);
@ -74,8 +74,8 @@
var request = new DefaultHttpContext().Request;
request.Method = "GET";
request.Path = new Microsoft.AspNet.Http.PathString("/Test");
var ac = new HttpContextAccessor() { Value = request.HttpContext };
ac.Value.RequestServices = new TestServiceProvider(new List<object>() { new RequestTelemetry() });
var ac = new HttpContextAccessor() { HttpContext = request.HttpContext };
ac.HttpContext.RequestServices = new TestServiceProvider(new List<object>() { new RequestTelemetry() });
var initializer = new OperationNameTelemetryInitializer(ac);
initializer.Initialize(telemetry);

Просмотреть файл

@ -4,7 +4,7 @@
using Microsoft.ApplicationInsights.AspNet.Tests.Helpers;
using Microsoft.ApplicationInsights.DataContracts;
using Microsoft.AspNet.Hosting;
using Microsoft.AspNet.Http.Core;
using Microsoft.AspNet.Http;
using System;
using System.Collections.Generic;
using Xunit;
@ -20,7 +20,7 @@
[Fact]
public void InitializeDoesNotThrowIfHttpContextIsUnavailable()
{
var ac = new HttpContextAccessor() { Value = null };
var ac = new HttpContextAccessor() { HttpContext = null };
var initializer = new UserAgentTelemetryInitializer(ac);
@ -30,7 +30,7 @@
[Fact]
public void InitializeDoesNotThrowIfRequestTelemetryIsUnavailable()
{
var ac = new HttpContextAccessor() { Value = new DefaultHttpContext() };
var ac = new HttpContextAccessor() { HttpContext = new DefaultHttpContext() };
var initializer = new UserAgentTelemetryInitializer(ac);
@ -41,9 +41,9 @@
public void InitializeSetsUserAgentFromHeader()
{
var requestTelemetry = new RequestTelemetry();
var ac = new HttpContextAccessor() { Value = new DefaultHttpContext() };
ac.Value.Request.Headers.Add("User-Agent", new[] { "test" });
ac.Value.RequestServices = new TestServiceProvider(new List<object>() { requestTelemetry });
var ac = new HttpContextAccessor() { HttpContext = new DefaultHttpContext() };
ac.HttpContext.Request.Headers.Add("User-Agent", new[] { "test" });
ac.HttpContext.RequestServices = new TestServiceProvider(new List<object>() { requestTelemetry });
var initializer = new UserAgentTelemetryInitializer(ac);
initializer.Initialize(requestTelemetry);
@ -56,8 +56,8 @@
{
var requestTelemetry = new RequestTelemetry();
requestTelemetry.Context.User.UserAgent = "Inline";
var ac = new HttpContextAccessor() { Value = new DefaultHttpContext() };
ac.Value.Request.Headers.Add("User-Agent", new[] { "test" });
var ac = new HttpContextAccessor() { HttpContext = new DefaultHttpContext() };
ac.HttpContext.Request.Headers.Add("User-Agent", new[] { "test" });
var serviceProvider = new TestServiceProvider(new List<object>() { requestTelemetry });
var initializer = new UserAgentTelemetryInitializer(ac);

Просмотреть файл

@ -6,8 +6,8 @@
using Microsoft.ApplicationInsights.AspNet.Tests.Helpers;
using Microsoft.ApplicationInsights.DataContracts;
using Microsoft.AspNet.Hosting;
using Microsoft.AspNet.Http.Core;
using Xunit;
using Microsoft.AspNet.Http;
public class WebSessionTelemetryInitializerTests
{
@ -20,7 +20,7 @@
[Fact]
public void InitializeDoesNotThrowIfHttpContextIsUnavailable()
{
var ac = new HttpContextAccessor() { Value = null };
var ac = new HttpContextAccessor() { HttpContext = null };
var initializer = new WebSessionTelemetryInitializer(ac);
@ -30,7 +30,7 @@
[Fact]
public void InitializeDoesNotThrowIfRequestTelemetryIsUnavailable()
{
var ac = new HttpContextAccessor() { Value = new DefaultHttpContext() };
var ac = new HttpContextAccessor() { HttpContext = new DefaultHttpContext() };
var initializer = new WebSessionTelemetryInitializer(ac);
@ -41,9 +41,9 @@
public void InitializeSetsSessionFromCookie()
{
var requestTelemetry = new RequestTelemetry();
var ac = new HttpContextAccessor() { Value = new DefaultHttpContext() };
ac.Value.Request.Headers["Cookie"] = "ai_session=test|2015-04-10T17:11:38.378Z|2015-04-10T17:11:39.180Z";
ac.Value.RequestServices = new TestServiceProvider(new List<object>() { requestTelemetry });
var ac = new HttpContextAccessor() { HttpContext = new DefaultHttpContext() };
ac.HttpContext.Request.Headers["Cookie"] = "ai_session=test|2015-04-10T17:11:38.378Z|2015-04-10T17:11:39.180Z";
ac.HttpContext.RequestServices = new TestServiceProvider(new List<object>() { requestTelemetry });
var initializer = new WebSessionTelemetryInitializer(ac);
initializer.Initialize(requestTelemetry);
@ -56,8 +56,8 @@
{
var requestTelemetry = new RequestTelemetry();
requestTelemetry.Context.Session.Id = "Inline";
var ac = new HttpContextAccessor() { Value = new DefaultHttpContext() };
ac.Value.Request.Headers["Cookie"] = "ai_session=test|2015-04-10T17:11:38.378Z|2015-04-10T17:11:39.180Z";
var ac = new HttpContextAccessor() { HttpContext = new DefaultHttpContext() };
ac.HttpContext.Request.Headers["Cookie"] = "ai_session=test|2015-04-10T17:11:38.378Z|2015-04-10T17:11:39.180Z";
var serviceProvider = new TestServiceProvider(new List<object>() { requestTelemetry });
var initializer = new WebSessionTelemetryInitializer(ac);

Просмотреть файл

@ -4,11 +4,11 @@
using Microsoft.ApplicationInsights.AspNet.Tests.Helpers;
using Microsoft.ApplicationInsights.DataContracts;
using Microsoft.AspNet.Hosting;
using Microsoft.AspNet.Http.Core;
using Microsoft.AspNet.Http;
using System;
using System.Collections.Generic;
using Xunit;
using System.Globalization;
using Xunit;
public class WebUserTelemetryInitializerTests
{
@ -21,7 +21,7 @@
[Fact]
public void InitializeDoesNotThrowIfHttpContextIsUnavailable()
{
var ac = new HttpContextAccessor() { Value = null };
var ac = new HttpContextAccessor() { HttpContext = null };
var initializer = new WebUserTelemetryInitializer(ac);
@ -31,7 +31,7 @@
[Fact]
public void InitializeDoesNotThrowIfRequestTelemetryIsUnavailable()
{
var ac = new HttpContextAccessor() { Value = new DefaultHttpContext() };
var ac = new HttpContextAccessor() { HttpContext = new DefaultHttpContext() };
var initializer = new WebUserTelemetryInitializer(ac);
@ -42,9 +42,9 @@
public void InitializeSetsUserFromCookie()
{
var requestTelemetry = new RequestTelemetry();
var ac = new HttpContextAccessor() { Value = new DefaultHttpContext() };
ac.Value.Request.Headers["Cookie"] = "ai_user=test|2015-04-09T21:51:59.993Z";
ac.Value.RequestServices = new TestServiceProvider(new List<object>() { requestTelemetry });
var ac = new HttpContextAccessor() { HttpContext = new DefaultHttpContext() };
ac.HttpContext.Request.Headers["Cookie"] = "ai_user=test|2015-04-09T21:51:59.993Z";
ac.HttpContext.RequestServices = new TestServiceProvider(new List<object>() { requestTelemetry });
var initializer = new WebUserTelemetryInitializer(ac);
initializer.Initialize(requestTelemetry);
@ -58,8 +58,8 @@
{
var requestTelemetry = new RequestTelemetry();
requestTelemetry.Context.User.Id = "Inline";
var ac = new HttpContextAccessor() { Value = new DefaultHttpContext() };
ac.Value.Request.Headers["Cookie"] = "ai_user=test|2015-04-09T21:51:59.993Z";
var ac = new HttpContextAccessor() { HttpContext = new DefaultHttpContext() };
ac.HttpContext.Request.Headers["Cookie"] = "ai_user=test|2015-04-09T21:51:59.993Z";
var serviceProvider = new TestServiceProvider(new List<object>() { requestTelemetry });
var initializer = new WebUserTelemetryInitializer(ac);
@ -72,8 +72,8 @@
public void InitializeDoesNotThrowOnMalformedUserCookie()
{
var requestTelemetry = new RequestTelemetry();
var ac = new HttpContextAccessor() { Value = new DefaultHttpContext() };
ac.Value.Request.Headers["Cookie"] = "ai_user=test";
var ac = new HttpContextAccessor() { HttpContext = new DefaultHttpContext() };
ac.HttpContext.Request.Headers["Cookie"] = "ai_user=test";
var serviceProvider = new TestServiceProvider(new List<object>() { requestTelemetry });
var initializer = new WebUserTelemetryInitializer(ac);
@ -86,9 +86,9 @@
public void InitializeDoesNotNotThrowOnMalformedAcquisitionDate()
{
var requestTelemetry = new RequestTelemetry();
var ac = new HttpContextAccessor() { Value = new DefaultHttpContext() };
ac.Value.Request.Headers["Cookie"] = "ai_user=test|malformeddate";
ac.Value.RequestServices = new TestServiceProvider(new List<object>() { requestTelemetry });
var ac = new HttpContextAccessor() { HttpContext = new DefaultHttpContext() };
ac.HttpContext.Request.Headers["Cookie"] = "ai_user=test|malformeddate";
ac.HttpContext.RequestServices = new TestServiceProvider(new List<object>() { requestTelemetry });
var initializer = new WebUserTelemetryInitializer(ac);
initializer.Initialize(requestTelemetry);

Просмотреть файл

@ -0,0 +1,21 @@
{
"dependencies": {
"Microsoft.ApplicationInsights.AspNet": "0.30.0.1-beta",
"xunit.runner.aspnet": "2.0.0-aspnet-beta5-*",
"Microsoft.AspNet.FeatureModel": "1.0.0-beta5-*",
"Microsoft.AspNet.Http": "1.0.0-beta5-*",
"Microsoft.AspNet.Http.Extensions": "1.0.0-beta5-*",
"Microsoft.AspNet.Hosting": "1.0.0-beta5-*",
"Microsoft.Framework.Logging": "1.0.0-beta5-*",
"Microsoft.AspNet.Mvc.Core": "6.0.0-beta5-*",
"Microsoft.Framework.ConfigurationModel.Json": "1.0.0-beta5-*"
},
"commands": {
"test": "xunit.runner.aspnet"
},
"frameworks": {
"dnx451": { },
"dnxcore50": {
}
}
}

Просмотреть файл

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Security.Principal;
using System.Threading.Tasks;
using Microsoft.AspNet.Authorization;
using Microsoft.AspNet.Identity;
using Microsoft.AspNet.Mvc;
using SampleWebAppIntegration.Models;
@ -148,7 +149,7 @@ namespace SampleWebAppIntegration.Controllers
private async Task<ApplicationUser> GetCurrentUserAsync()
{
return await UserManager.FindByIdAsync(Context.User.Identity.GetUserId());
return await UserManager.FindByNameAsync(Context.User.Identity.Name);
}
public enum ManageMessageId

Просмотреть файл

@ -1,240 +0,0 @@
using System;
using Microsoft.Data.Entity;
using Microsoft.Data.Entity.Metadata;
using Microsoft.Data.Entity.Relational.Migrations;
using Microsoft.Data.Entity.Relational.Migrations.Builders;
using Microsoft.Data.Entity.Relational.Migrations.Infrastructure;
namespace SampleWebAppIntegration.Migrations
{
public partial class CreateIdentitySchema : Migration
{
public override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable("AspNetRoles",
c => new
{
Id = c.String(),
Name = c.String()
})
.PrimaryKey("PK_AspNetRoles", t => t.Id);
migrationBuilder.CreateTable("AspNetRoleClaims",
c => new
{
Id = c.Int(nullable: false, identity: true),
ClaimType = c.String(),
ClaimValue = c.String(),
RoleId = c.String()
})
.PrimaryKey("PK_AspNetRoleClaims", t => t.Id);
migrationBuilder.CreateTable("AspNetUserClaims",
c => new
{
Id = c.Int(nullable: false, identity: true),
ClaimType = c.String(),
ClaimValue = c.String(),
UserId = c.String()
})
.PrimaryKey("PK_AspNetUserClaims", t => t.Id);
migrationBuilder.CreateTable("AspNetUserLogins",
c => new
{
LoginProvider = c.String(),
ProviderKey = c.String(),
ProviderDisplayName = c.String(),
UserId = c.String()
})
.PrimaryKey("PK_AspNetUserLogins", t => new { t.LoginProvider, t.ProviderKey });
migrationBuilder.CreateTable("AspNetUserRoles",
c => new
{
UserId = c.String(),
RoleId = c.String()
})
.PrimaryKey("PK_AspNetUserRoles", t => new { t.UserId, t.RoleId });
migrationBuilder.CreateTable("AspNetUsers",
c => new
{
Id = c.String(),
AccessFailedCount = c.Int(nullable: false),
ConcurrencyStamp = c.String(),
Email = c.String(),
EmailConfirmed = c.Boolean(nullable: false),
LockoutEnabled = c.Boolean(nullable: false),
LockoutEnd = c.DateTimeOffset(),
NormalizedEmail = c.String(),
NormalizedUserName = c.String(),
PasswordHash = c.String(),
PhoneNumber = c.String(),
PhoneNumberConfirmed = c.Boolean(nullable: false),
SecurityStamp = c.String(),
TwoFactorEnabled = c.Boolean(nullable: false),
UserName = c.String()
})
.PrimaryKey("PK_AspNetUsers", t => t.Id);
migrationBuilder.AddForeignKey(
"AspNetRoleClaims",
"FK_AspNetRoleClaims_AspNetRoles_RoleId",
new[] { "RoleId" },
"AspNetRoles",
new[] { "Id" },
cascadeDelete: false);
migrationBuilder.AddForeignKey(
"AspNetUserClaims",
"FK_AspNetUserClaims_AspNetUsers_UserId",
new[] { "UserId" }, "AspNetUsers",
new[] { "Id" },
cascadeDelete: false);
migrationBuilder.AddForeignKey(
"AspNetUserLogins",
"FK_AspNetUserLogins_AspNetUsers_UserId",
new[] { "UserId" },
"AspNetUsers",
new[] { "Id" },
cascadeDelete: false);
}
public override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey("AspNetRoleClaims", "FK_AspNetRoleClaims_AspNetRoles_RoleId");
migrationBuilder.DropForeignKey("AspNetUserClaims", "FK_AspNetUserClaims_AspNetUsers_UserId");
migrationBuilder.DropForeignKey("AspNetUserLogins", "FK_AspNetUserLogins_AspNetUsers_UserId");
migrationBuilder.DropTable("AspNetRoles");
migrationBuilder.DropTable("AspNetRoleClaims");
migrationBuilder.DropTable("AspNetUserClaims");
migrationBuilder.DropTable("AspNetUserLogins");
migrationBuilder.DropTable("AspNetUserRoles");
migrationBuilder.DropTable("AspNetUsers");
}
}
[ContextType(typeof(Models.ApplicationDbContext))]
public partial class CreateIdentitySchema : IMigrationMetadata
{
string IMigrationMetadata.MigrationId
{
get
{
return "000000000000000_CreateIdentitySchema";
}
}
string IMigrationMetadata.ProductVersion
{
get
{
return "7.0.0-beta2";
}
}
IModel IMigrationMetadata.TargetModel
{
get
{
var builder = new BasicModelBuilder();
builder.Entity("Microsoft.AspNet.Identity.IdentityRole", b =>
{
b.Property<string>("Id");
b.Property<string>("Name");
b.Key("Id");
b.ForRelational().Table("AspNetRoles");
});
builder.Entity("Microsoft.AspNet.Identity.IdentityRoleClaim`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]", b =>
{
b.Property<string>("ClaimType");
b.Property<string>("ClaimValue");
b.Property<int>("Id")
.GenerateValueOnAdd();
b.Property<string>("RoleId");
b.Key("Id");
b.ForRelational().Table("AspNetRoleClaims");
});
builder.Entity("Microsoft.AspNet.Identity.IdentityUserClaim`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]", b =>
{
b.Property<string>("ClaimType");
b.Property<string>("ClaimValue");
b.Property<int>("Id")
.GenerateValueOnAdd();
b.Property<string>("UserId");
b.Key("Id");
b.ForRelational().Table("AspNetUserClaims");
});
builder.Entity("Microsoft.AspNet.Identity.IdentityUserLogin`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]", b =>
{
b.Property<string>("LoginProvider");
b.Property<string>("ProviderDisplayName");
b.Property<string>("ProviderKey");
b.Property<string>("UserId");
b.Key("LoginProvider", "ProviderKey");
b.ForRelational().Table("AspNetUserLogins");
});
builder.Entity("Microsoft.AspNet.Identity.IdentityUserRole`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]", b =>
{
b.Property<string>("RoleId");
b.Property<string>("UserId");
b.Key("UserId", "RoleId");
b.ForRelational().Table("AspNetUserRoles");
});
builder.Entity("SampleWebAppIntegration.Models.ApplicationUser", b =>
{
b.Property<int>("AccessFailedCount");
b.Property<string>("ConcurrencyStamp");
b.Property<string>("Email");
b.Property<bool>("EmailConfirmed");
b.Property<string>("Id");
b.Property<bool>("LockoutEnabled");
b.Property<DateTimeOffset?>("LockoutEnd");
b.Property<string>("NormalizedEmail");
b.Property<string>("NormalizedUserName");
b.Property<string>("PasswordHash");
b.Property<string>("PhoneNumber");
b.Property<bool>("PhoneNumberConfirmed");
b.Property<string>("SecurityStamp");
b.Property<bool>("TwoFactorEnabled");
b.Property<string>("UserName");
b.Key("Id");
b.ForRelational().Table("AspNetUsers");
});
builder.Entity("Microsoft.AspNet.Identity.IdentityRoleClaim`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]", b =>
{
b.ForeignKey("Microsoft.AspNet.Identity.IdentityRole", "RoleId");
});
builder.Entity("Microsoft.AspNet.Identity.IdentityUserClaim`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]", b =>
{
b.ForeignKey("SampleWebAppIntegration.Models.ApplicationUser", "UserId");
});
builder.Entity("Microsoft.AspNet.Identity.IdentityUserLogin`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]", b =>
{
b.ForeignKey("SampleWebAppIntegration.Models.ApplicationUser", "UserId");
});
return builder.Model;
}
}
}
}

Просмотреть файл

@ -1,6 +1,7 @@
using System;
using Microsoft.Data.Entity;
using Microsoft.Data.Entity.Metadata;
using Microsoft.Data.Entity.Metadata.Builders;
using Microsoft.Data.Entity.Relational.Migrations.Infrastructure;
using SampleWebAppIntegration.Models;
@ -20,7 +21,7 @@ namespace SampleWebAppIntegration.Migrations
b.Property<string>("Id");
b.Property<string>("Name");
b.Key("Id");
b.ForRelational().Table("AspNetRoles");
b.Metadata.Relational().Table = "AspNetRoles";
});
builder.Entity("Microsoft.AspNet.Identity.IdentityRoleClaim`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]", b =>
@ -31,7 +32,7 @@ namespace SampleWebAppIntegration.Migrations
.GenerateValueOnAdd();
b.Property<string>("RoleId");
b.Key("Id");
b.ForRelational().Table("AspNetRoleClaims");
b.Metadata.Relational().Table = "AspNetRoleClaims";
});
builder.Entity("Microsoft.AspNet.Identity.IdentityUserClaim`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]", b =>
@ -42,7 +43,8 @@ namespace SampleWebAppIntegration.Migrations
.GenerateValueOnAdd();
b.Property<string>("UserId");
b.Key("Id");
b.ForRelational().Table("AspNetUserClaims");
b.Metadata.Relational().Table = "AspNetUserClaims";
});
builder.Entity("Microsoft.AspNet.Identity.IdentityUserLogin`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]", b =>
@ -52,7 +54,7 @@ namespace SampleWebAppIntegration.Migrations
b.Property<string>("ProviderKey");
b.Property<string>("UserId");
b.Key("LoginProvider", "ProviderKey");
b.ForRelational().Table("AspNetUserLogins");
b.Metadata.Relational().Table = "AspNetUserLogins";
});
builder.Entity("Microsoft.AspNet.Identity.IdentityUserRole`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]", b =>
@ -60,7 +62,7 @@ namespace SampleWebAppIntegration.Migrations
b.Property<string>("RoleId");
b.Property<string>("UserId");
b.Key("UserId", "RoleId");
b.ForRelational().Table("AspNetUserRoles");
b.Metadata.Relational().Table = "AspNetUserRoles";
});
builder.Entity("SampleWebAppIntegration.Models.ApplicationUser", b =>
@ -81,7 +83,7 @@ namespace SampleWebAppIntegration.Migrations
b.Property<bool>("TwoFactorEnabled");
b.Property<string>("UserName");
b.Key("Id");
b.ForRelational().Table("AspNetUsers");
b.Metadata.Relational().Table = "AspNetUsers";
});
builder.Entity("Microsoft.AspNet.Identity.IdentityRoleClaim`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]", b =>

Просмотреть файл

@ -24,14 +24,14 @@ namespace SampleWebAppIntegration.Models
// are supported in ASP.NET 5
if (!_created)
{
Database.AsMigrationsEnabled().ApplyMigrations();
Database.AsSqlServer().ApplyMigrations();
_created = true;
}
}
protected override void OnConfiguring(DbContextOptions options)
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
options.UseSqlServer();
optionsBuilder.UseSqlServer(this.Database.AsSqlServer().Connection.ConnectionString);
}
protected override void OnModelCreating(ModelBuilder builder)

Просмотреть файл

@ -4,7 +4,6 @@
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(VSToolsPath)\AspNet\Microsoft.Web.AspNet.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>330152ec-1092-41f0-9f96-c3438e07fcc2</ProjectGuid>
<RootNamespace>SampleWebAppIntegration</RootNamespace>
@ -15,5 +14,9 @@
<SchemaVersion>2.0</SchemaVersion>
<DevelopmentServerPort>54056</DevelopmentServerPort>
</PropertyGroup>
<Import Project="$(VSToolsPath)\AspNet\Microsoft.Web.AspNet.targets" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<ProduceOutputsOnBuild>True</ProduceOutputsOnBuild>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" />
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" />
</Project>

Просмотреть файл

@ -1,16 +1,17 @@
using FunctionalTestUtils;
using System;
using FunctionalTestUtils;
using Microsoft.ApplicationInsights.AspNet;
using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Diagnostics;
using Microsoft.AspNet.Diagnostics.Entity;
using Microsoft.AspNet.Hosting;
using Microsoft.AspNet.Identity;
using Microsoft.AspNet.Identity.EntityFramework;
using Microsoft.Framework.ConfigurationModel;
using Microsoft.Framework.DependencyInjection;
using Microsoft.Framework.Logging;
using Microsoft.Framework.Logging.Console;
using SampleWebAppIntegration.Models;
using System;
namespace SampleWebAppIntegration
{
@ -19,7 +20,7 @@ namespace SampleWebAppIntegration
public Startup(IHostingEnvironment env)
{
// Setup configuration sources.
Configuration = new Configuration()
Configuration = new Configuration(".")
.AddJsonFile("config.json")
.AddEnvironmentVariables();
}
@ -33,12 +34,12 @@ namespace SampleWebAppIntegration
services.AddApplicationInsightsTelemetry(Configuration);
// Add EF services to the services container.
services.AddEntityFramework(Configuration)
services.AddEntityFramework()
.AddSqlServer()
.AddDbContext<ApplicationDbContext>();
// Add Identity services to the services container.
services.AddIdentity<ApplicationUser, IdentityRole>(Configuration)
services.AddIdentity<ApplicationUser, IdentityRole>()
.AddEntityFrameworkStores<ApplicationDbContext>();
// Add MVC services to the services container.
@ -64,7 +65,7 @@ namespace SampleWebAppIntegration
// Add the following to the request pipeline only in development environment.
if (string.Equals(env.EnvironmentName, "Development", StringComparison.OrdinalIgnoreCase))
{
app.UseBrowserLink();
//app.UseBrowserLink();
app.UseErrorPage(ErrorPageOptions.ShowAll);
app.UseDatabaseErrorPage(DatabaseErrorPageOptions.ShowAll);
// Set immediate delivery for Application Insights events.

Просмотреть файл

@ -1,7 +1,7 @@
@using System.Security.Principal
@model SampleWebAppIntegration.Models.ManageUserViewModel
<p>You're logged in as <strong>@User.Identity.GetUserName()</strong>.</p>
<p>You're logged in as <strong>@User.Identity.Name</strong>.</p>
@using (Html.BeginForm("Manage", "Account", FormMethod.Post, new { @class = "form-horizontal", role = "form" }))
{

Просмотреть файл

@ -7,7 +7,7 @@
@Html.AntiForgeryToken()
<ul class="nav navbar-nav navbar-right">
<li>
@Html.ActionLink("Hello " + User.Identity.GetUserName() + "!", "Manage", "Account", routeValues: null, htmlAttributes: new { title = "Manage" })
@Html.ActionLink("Hello " + User.Identity.Name + "!", "Manage", "Account", routeValues: null, htmlAttributes: new { title = "Manage" })
</li>
<li><a href="javascript:document.getElementById('logoutForm').submit()">Log off</a></li>
</ul>

Просмотреть файл

@ -3,28 +3,28 @@
"webroot": "wwwroot",
"version": "1.0.0-*",
"dependencies": {
"EntityFramework.SqlServer": "7.0.0-beta3",
"EntityFramework.Commands": "7.0.0-beta3",
"Microsoft.AspNet.Mvc": "6.0.0-beta3",
/* "Microsoft.AspNet.Mvc.WebApiCompatShim": "6.0.0-beta3", */
"Microsoft.AspNet.Diagnostics": "1.0.0-beta3",
"Microsoft.AspNet.Diagnostics.Entity": "7.0.0-beta3",
"Microsoft.AspNet.Identity.EntityFramework": "3.0.0-beta3",
"Microsoft.AspNet.Security.Cookies": "1.0.0-beta3",
"Microsoft.AspNet.Server.IIS": "1.0.0-beta3",
"Microsoft.AspNet.Server.WebListener": "1.0.0-beta3",
"Microsoft.AspNet.StaticFiles": "1.0.0-beta3",
"Microsoft.Framework.ConfigurationModel.Json": "1.0.0-beta3",
"Microsoft.Framework.CodeGenerators.Mvc": "1.0.0-beta3",
"Microsoft.Framework.Logging": "1.0.0-beta3",
"Microsoft.Framework.Logging.Console": "1.0.0-beta3",
"EntityFramework.SqlServer": "7.0.0-beta5-*",
"EntityFramework.SqlServer.Design": "7.0.0-beta5-*",
"EntityFramework.Core": "7.0.0-beta5-*",
"EntityFramework.Commands": "7.0.0-beta5-*",
"Microsoft.AspNet.Mvc": "6.0.0-beta5-*",
"Microsoft.AspNet.Diagnostics": "1.0.0-beta5-*",
"Microsoft.AspNet.Diagnostics.Entity": "7.0.0-beta5-*",
"Microsoft.AspNet.Identity.EntityFramework": "3.0.0-beta5-*",
"Microsoft.AspNet.Server.IIS": "1.0.0-beta5-*",
"Microsoft.AspNet.Server.WebListener": "1.0.0-beta5-*",
"Microsoft.AspNet.StaticFiles": "1.0.0-beta5-*",
"Microsoft.Framework.ConfigurationModel.Json": "1.0.0-beta5-*",
"Microsoft.Framework.CodeGenerators.Mvc": "1.0.0-beta5-*",
"Microsoft.Framework.Logging": "1.0.0-beta5-*",
"Microsoft.Framework.Logging.Console": "1.0.0-beta5-*",
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-beta3",
"ApplicationInsights.AspNet": "0.30.0.1-beta",
"Microsoft.ApplicationInsights.AspNet": "0.30.0.1-beta",
"FunctionalTestUtils": "1.0.0-*",
"xunit": "2.1.0.0-beta1-build2945",
"xunit.runner.aspnet": "2.1.0.0-beta1-build60",
"xunit.runner.visualstudio": "2.1.0.0-beta1-build1051",
"Microsoft.AspNet.Mvc.WebApiCompatShim": "6.0.0-beta3"
"xunit.runner.aspnet": "2.0.0-aspnet-beta5-*",
"Microsoft.AspNet.Mvc.WebApiCompatShim": "6.0.0-beta5-*",
"System.Runtime": "4.0.20-beta-*",
"Microsoft.Framework.Runtime": "1.0.0-beta5-*"
},
"commands": {
/* Change the port number when you are self hosting this application */
@ -34,15 +34,18 @@
"test": "xunit.runner.aspnet"
},
"frameworks": {
"aspnet50": { },
"aspnetcore50": { }
"dnx451": {
"dependencies": {
"System.Runtime": "4.0.20-beta-*"
}
}
},
"exclude": [
"wwwroot",
"node_modules",
"bower_components"
],
"bundleExclude": [
"publishExclude": [
"node_modules",
"bower_components",
"**.kproj",