diff --git a/Mvc.sln b/Mvc.sln index aa6260411f..69dfa9cbc4 100644 --- a/Mvc.sln +++ b/Mvc.sln @@ -118,6 +118,8 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "ActionResultsWebSite", "tes EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "LoggingWebSite", "test\WebSites\LoggingWebSite\LoggingWebSite.kproj", "{0AD78AB5-D67C-49BC-81B1-0C51BFA82B5E}" EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "ErrorPageMiddlewareWebSite", "test\WebSites\ErrorPageMiddlewareWebSite\ErrorPageMiddlewareWebSite.kproj", "{AD545A5B-2BA5-4314-88AC-FC2ACF2CC718}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -650,6 +652,18 @@ Global {0AD78AB5-D67C-49BC-81B1-0C51BFA82B5E}.Release|Mixed Platforms.Build.0 = Release|Any CPU {0AD78AB5-D67C-49BC-81B1-0C51BFA82B5E}.Release|x86.ActiveCfg = Release|Any CPU {0AD78AB5-D67C-49BC-81B1-0C51BFA82B5E}.Release|x86.Build.0 = Release|Any CPU + {AD545A5B-2BA5-4314-88AC-FC2ACF2CC718}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AD545A5B-2BA5-4314-88AC-FC2ACF2CC718}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AD545A5B-2BA5-4314-88AC-FC2ACF2CC718}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {AD545A5B-2BA5-4314-88AC-FC2ACF2CC718}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {AD545A5B-2BA5-4314-88AC-FC2ACF2CC718}.Debug|x86.ActiveCfg = Debug|Any CPU + {AD545A5B-2BA5-4314-88AC-FC2ACF2CC718}.Debug|x86.Build.0 = Debug|Any CPU + {AD545A5B-2BA5-4314-88AC-FC2ACF2CC718}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AD545A5B-2BA5-4314-88AC-FC2ACF2CC718}.Release|Any CPU.Build.0 = Release|Any CPU + {AD545A5B-2BA5-4314-88AC-FC2ACF2CC718}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {AD545A5B-2BA5-4314-88AC-FC2ACF2CC718}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {AD545A5B-2BA5-4314-88AC-FC2ACF2CC718}.Release|x86.ActiveCfg = Release|Any CPU + {AD545A5B-2BA5-4314-88AC-FC2ACF2CC718}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -707,5 +721,6 @@ Global {920F8A0E-6F7D-4BBE-84FF-840B89099BE6} = {16703B76-C9F7-4C75-AE6C-53D92E308E3C} {0A6BB4C0-48D3-4E7F-952B-B8917345E075} = {16703B76-C9F7-4C75-AE6C-53D92E308E3C} {0AD78AB5-D67C-49BC-81B1-0C51BFA82B5E} = {16703B76-C9F7-4C75-AE6C-53D92E308E3C} + {AD545A5B-2BA5-4314-88AC-FC2ACF2CC718} = {16703B76-C9F7-4C75-AE6C-53D92E308E3C} EndGlobalSection EndGlobal diff --git a/src/Microsoft.AspNet.Mvc.Razor/Compilation/CompilationFailedException.cs b/src/Microsoft.AspNet.Mvc.Razor/Compilation/CompilationFailedException.cs index 2b81c500aa..3e1b7ac600 100644 --- a/src/Microsoft.AspNet.Mvc.Razor/Compilation/CompilationFailedException.cs +++ b/src/Microsoft.AspNet.Mvc.Razor/Compilation/CompilationFailedException.cs @@ -3,70 +3,28 @@ using System; using System.Collections.Generic; -using System.Linq; +using Microsoft.AspNet.Diagnostics; namespace Microsoft.AspNet.Mvc.Razor { /// /// An exception thrown when accessing the result of a failed compilation. /// - public class CompilationFailedException : Exception + public class CompilationFailedException : Exception, ICompilationException { /// /// Instantiates a new instance of . /// - /// The path of the Razor source file that was compiled. - /// The contents of the Razor source file. - /// The generated C# content that was compiled. - /// A sequence of encountered - /// during compilation. + /// The instance containing + /// details of the compilation failure. public CompilationFailedException( - [NotNull] string filePath, - [NotNull] string fileContent, - [NotNull] string compiledContent, - [NotNull] IEnumerable messages) - : base(FormatMessage(messages)) + [NotNull] ICompilationFailure compilationFailure) + : base(Resources.FormatCompilationFailed(compilationFailure.SourceFilePath)) { - FilePath = filePath; - FileContent = fileContent; - CompiledContent = compiledContent; - Messages = messages.ToList(); + CompilationFailures = new[] { compilationFailure }; } - /// - /// Gets the path of the Razor source file that produced the compilation failure. - /// - public string FilePath { get; private set; } - - /// - /// Gets a sequence of instances encountered during compilation. - /// - public IEnumerable Messages { get; private set; } - - /// - /// Gets the content of the Razor source file. - /// - public string FileContent { get; private set; } - - /// - /// Gets the generated C# content that was compiled. - /// - public string CompiledContent { get; private set; } - /// - public override string Message - { - get - { - return Resources.FormatCompilationFailed(FilePath) + - Environment.NewLine + - FormatMessage(Messages); - } - } - - private static string FormatMessage(IEnumerable messages) - { - return string.Join(Environment.NewLine, messages); - } + public IEnumerable CompilationFailures { get; } } } diff --git a/src/Microsoft.AspNet.Mvc.Razor/Compilation/CompilationFailure.cs b/src/Microsoft.AspNet.Mvc.Razor/Compilation/CompilationFailure.cs new file mode 100644 index 0000000000..f014061ad4 --- /dev/null +++ b/src/Microsoft.AspNet.Mvc.Razor/Compilation/CompilationFailure.cs @@ -0,0 +1,52 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Collections.Generic; +using Microsoft.AspNet.Diagnostics; + +namespace Microsoft.AspNet.Mvc.Razor +{ + /// + /// Default implementation of . + /// + public class CompilationFailure : ICompilationFailure + { + /// Initializes a new instance of . + /// The path of the Razor source file that was compiled. + /// The contents of the Razor source file. + /// The generated C# content that was compiled. + /// A sequence of encountered + /// during compilation. + public CompilationFailure( + [NotNull] string filePath, + [NotNull] string fileContent, + [NotNull] string compiledContent, + [NotNull] IEnumerable messages) + { + SourceFilePath = filePath; + SourceFileContent = fileContent; + Messages = messages; + CompiledContent = compiledContent; + } + + /// + /// Gets the path of the Razor source file that produced the compilation failure. + /// + public string SourceFilePath { get; } + + /// + /// Gets the content of the Razor source file. + /// + public string SourceFileContent { get; } + + /// + /// Gets the generated C# content that was compiled. + /// + public string CompiledContent { get; } + + /// + /// Gets a sequence of instances encountered during compilation. + /// + public IEnumerable Messages { get; } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.Mvc.Razor/Compilation/CompilationMessage.cs b/src/Microsoft.AspNet.Mvc.Razor/Compilation/CompilationMessage.cs index a99e80d4c9..b0b6e615a2 100644 --- a/src/Microsoft.AspNet.Mvc.Razor/Compilation/CompilationMessage.cs +++ b/src/Microsoft.AspNet.Mvc.Razor/Compilation/CompilationMessage.cs @@ -1,26 +1,48 @@ // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using Microsoft.AspNet.Diagnostics; + namespace Microsoft.AspNet.Mvc.Razor { /// /// Represents a message encountered during compilation. /// - public class CompilationMessage + public class CompilationMessage : ICompilationMessage { /// /// Initializes a with the specified message. /// /// A message produced from compilation. - public CompilationMessage(string message) + public CompilationMessage(string message, + int startColumn, + int startLine, + int endColumn, + int endLine) { Message = message; + StartColumn = startColumn; + StartLine = startLine; + EndColumn = endColumn; + EndLine = endLine; } /// /// Gets a message produced from compilation. /// - public string Message { get; private set; } + public string Message { get; } + + /// + public int StartColumn { get; } + + /// + public int StartLine { get; } + + /// + public int EndColumn { get; } + + /// + public int EndLine { get; } /// /// Returns a representation of this instance of . diff --git a/src/Microsoft.AspNet.Mvc.Razor/Compilation/CompilationResult.cs b/src/Microsoft.AspNet.Mvc.Razor/Compilation/CompilationResult.cs index 6c6daba5e8..85dab4a29b 100644 --- a/src/Microsoft.AspNet.Mvc.Razor/Compilation/CompilationResult.cs +++ b/src/Microsoft.AspNet.Mvc.Razor/Compilation/CompilationResult.cs @@ -105,7 +105,8 @@ namespace Microsoft.AspNet.Mvc.Razor private CompilationFailedException CreateCompilationFailedException() { var fileContent = ReadContent(File); - return new CompilationFailedException(FilePath, fileContent, CompiledContent, Messages); + var compilationFailure = new CompilationFailure(FilePath, fileContent, CompiledContent, Messages); + return new CompilationFailedException(compilationFailure); } private static string ReadContent(IFileInfo file) diff --git a/src/Microsoft.AspNet.Mvc.Razor/Compilation/RoslynCompilationService.cs b/src/Microsoft.AspNet.Mvc.Razor/Compilation/RoslynCompilationService.cs index 43f236a1bc..e2bf974897 100644 --- a/src/Microsoft.AspNet.Mvc.Razor/Compilation/RoslynCompilationService.cs +++ b/src/Microsoft.AspNet.Mvc.Razor/Compilation/RoslynCompilationService.cs @@ -197,7 +197,12 @@ namespace Microsoft.AspNet.Mvc.Razor private static CompilationMessage GetCompilationMessage(DiagnosticFormatter formatter, Diagnostic diagnostic) { - return new CompilationMessage(formatter.Format(diagnostic)); + var lineSpan = diagnostic.Location.GetMappedLineSpan(); + return new CompilationMessage(formatter.Format(diagnostic), + startColumn: lineSpan.StartLinePosition.Character, + startLine: lineSpan.StartLinePosition.Line, + endColumn: lineSpan.EndLinePosition.Character, + endLine: lineSpan.EndLinePosition.Line); } private static bool IsError(Diagnostic diagnostic) diff --git a/src/Microsoft.AspNet.Mvc.Razor/Diagnostics/ICompilationException.cs b/src/Microsoft.AspNet.Mvc.Razor/Diagnostics/ICompilationException.cs new file mode 100644 index 0000000000..ba9102a35b --- /dev/null +++ b/src/Microsoft.AspNet.Mvc.Razor/Diagnostics/ICompilationException.cs @@ -0,0 +1,20 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Collections.Generic; +using Microsoft.Framework.Runtime; + +namespace Microsoft.AspNet.Diagnostics +{ + /// + /// Specifies the contract for an exception representing compilation failure. + /// + [AssemblyNeutral] + public interface ICompilationException + { + /// + /// Gets a sequence of with compilation failures. + /// + IEnumerable CompilationFailures { get; } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.Mvc.Razor/Diagnostics/ICompilationFailure.cs b/src/Microsoft.AspNet.Mvc.Razor/Diagnostics/ICompilationFailure.cs new file mode 100644 index 0000000000..bf16458fc6 --- /dev/null +++ b/src/Microsoft.AspNet.Mvc.Razor/Diagnostics/ICompilationFailure.cs @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Collections.Generic; +using Microsoft.Framework.Runtime; + +namespace Microsoft.AspNet.Diagnostics +{ + /// + /// Specifies the contract for a file that fails compilation. + /// + [AssemblyNeutral] + public interface ICompilationFailure + { + /// + /// Path of the file that produced the compilation exception. + /// + string SourceFilePath { get; } + + /// + /// Contents of the file. + /// + string SourceFileContent { get; } + + /// + /// Contents being compiled. + /// + /// + /// For templated files, the represents the original content and + /// represents the transformed content. This property can be null if + /// the exception is encountered during transformation. + /// + string CompiledContent { get; } + + /// + /// Gets a sequence of produced as a result of compilation. + /// + IEnumerable Messages { get; } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.Mvc.Razor/Diagnostics/ICompilationMessage.cs b/src/Microsoft.AspNet.Mvc.Razor/Diagnostics/ICompilationMessage.cs new file mode 100644 index 0000000000..ed3ca5fed8 --- /dev/null +++ b/src/Microsoft.AspNet.Mvc.Razor/Diagnostics/ICompilationMessage.cs @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using Microsoft.Framework.Runtime; + +namespace Microsoft.AspNet.Diagnostics +{ + /// + /// Specifies the contract for diagnostic messages produced as result of compiling an instance + /// of . + /// + [AssemblyNeutral] + public interface ICompilationMessage + { + /// + /// Gets the error message. + /// + string Message { get; } + + /// + /// Gets the zero-based line index for the start of the compilation error. + /// + int StartLine { get; } + + /// + /// Gets the zero-based column index for the start of the compilation error. + /// + int StartColumn { get; } + + /// + /// Gets the zero-based line index for the end of the compilation error. + /// + int EndLine { get; } + + /// + /// Gets the zero-based column index for the end of the compilation error. + /// + int EndColumn { get; } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.Mvc.Razor/Properties/Resources.Designer.cs b/src/Microsoft.AspNet.Mvc.Razor/Properties/Resources.Designer.cs index cdfe251772..800c443b7b 100644 --- a/src/Microsoft.AspNet.Mvc.Razor/Properties/Resources.Designer.cs +++ b/src/Microsoft.AspNet.Mvc.Razor/Properties/Resources.Designer.cs @@ -27,7 +27,7 @@ namespace Microsoft.AspNet.Mvc.Razor } /// - /// Compilation for '{0}' failed: + /// Error compiling page at '{0}'. /// internal static string CompilationFailed { @@ -35,7 +35,7 @@ namespace Microsoft.AspNet.Mvc.Razor } /// - /// Compilation for '{0}' failed: + /// Error compiling page at '{0}'. /// internal static string FormatCompilationFailed(object p0) { diff --git a/src/Microsoft.AspNet.Mvc.Razor/Razor/RazorCompilationService.cs b/src/Microsoft.AspNet.Mvc.Razor/Razor/RazorCompilationService.cs index 51a317b0c5..52a38b24d4 100644 --- a/src/Microsoft.AspNet.Mvc.Razor/Razor/RazorCompilationService.cs +++ b/src/Microsoft.AspNet.Mvc.Razor/Razor/RazorCompilationService.cs @@ -33,7 +33,13 @@ namespace Microsoft.AspNet.Mvc.Razor if (!results.Success) { - var messages = results.ParserErrors.Select(e => new CompilationMessage(e.Message)); + var messages = results.ParserErrors + .Select(parseError => + new CompilationMessage(parseError.Message, + parseError.Location.CharacterIndex, + parseError.Location.LineIndex, + parseError.Location.CharacterIndex + parseError.Length, + parseError.Location.LineIndex)); return CompilationResult.Failed(file.FileInfo, results.GeneratedCode, messages); } diff --git a/src/Microsoft.AspNet.Mvc.Razor/Resources.resx b/src/Microsoft.AspNet.Mvc.Razor/Resources.resx index 0b494963f7..214cb7ba56 100644 --- a/src/Microsoft.AspNet.Mvc.Razor/Resources.resx +++ b/src/Microsoft.AspNet.Mvc.Razor/Resources.resx @@ -1,17 +1,17 @@  - @@ -121,7 +121,7 @@ Value cannot be null or empty. - Compilation for '{0}' failed: + Error compiling page at '{0}'. '{0}' cannot be invoked when a Layout page is set to be executed. diff --git a/test/Microsoft.AspNet.Mvc.FunctionalTests/ErrorPageTests.cs b/test/Microsoft.AspNet.Mvc.FunctionalTests/ErrorPageTests.cs new file mode 100644 index 0000000000..2cec3731c5 --- /dev/null +++ b/test/Microsoft.AspNet.Mvc.FunctionalTests/ErrorPageTests.cs @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Net; +using System.Net.Http.Headers; +using System.Reflection; +using System.Threading.Tasks; +using ErrorPageMiddlewareWebSite; +using Microsoft.AspNet.Builder; +using Microsoft.AspNet.TestHost; +using Xunit; + +namespace Microsoft.AspNet.Mvc.FunctionalTests +{ + /// + /// Functional test to verify the error reporting of Razor compilation by diagnostic middleware. + /// + public class ErrorPageTests + { + private readonly IServiceProvider _provider = TestHelper.CreateServices(nameof(ErrorPageMiddlewareWebSite)); + private readonly Action _app = new Startup().Configure; + private readonly Assembly _resourcesAssembly = typeof(ErrorPageTests).GetTypeInfo().Assembly; + + [Theory] + [InlineData("CompilationFailure", "/Views/ErrorPageMiddleware/CompilationFailure.cshtml(2,16): error CS0029:" + + " Cannot implicitly convert type 'int' to 'string'")] + [InlineData("ParserError", "The code block is missing a closing "}" character. Make sure you " + + "have a matching "}" character for all the "{" characters " + + "within this block, and that none of the "}" characters are being " + + "interpreted as markup.")] + public async Task CompilationFailuresAreListedByErrorPageMiddleware(string action, string expected) + { + // Arrange + var server = TestServer.Create(_provider, _app); + var client = server.CreateClient(); + var expectedMediaType = MediaTypeHeaderValue.Parse("text/html"); + + // Act + var response = await client.GetAsync("http://localhost/" + action); + + // Assert + Assert.Equal(HttpStatusCode.InternalServerError, response.StatusCode); + Assert.Equal(expectedMediaType, response.Content.Headers.ContentType); + var content = await response.Content.ReadAsStringAsync(); + Assert.Contains(expected, content); + } + } +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.Mvc.FunctionalTests/project.json b/test/Microsoft.AspNet.Mvc.FunctionalTests/project.json index a9669ca8df..80f87a620b 100644 --- a/test/Microsoft.AspNet.Mvc.FunctionalTests/project.json +++ b/test/Microsoft.AspNet.Mvc.FunctionalTests/project.json @@ -12,6 +12,7 @@ "BasicWebSite": "1.0.0", "CompositeViewEngineWebSite": "1.0.0", "ConnegWebSite": "1.0.0", + "ErrorPageMiddlewareWebSite": "1.0.0", "FilesWebSite": "1.0.0", "FiltersWebSite": "1.0.0", "FormatterWebSite": "1.0.0", @@ -49,6 +50,6 @@ "AutofacWebSite": "1.0.0" } }, - "aspnetcore50": {} + "aspnetcore50": { } } } diff --git a/test/Microsoft.AspNet.Mvc.Razor.Test/Compilation/CompilationResultTest.cs b/test/Microsoft.AspNet.Mvc.Razor.Test/Compilation/CompilationResultTest.cs index c32c347ce8..5334f46726 100644 --- a/test/Microsoft.AspNet.Mvc.Razor.Test/Compilation/CompilationResultTest.cs +++ b/test/Microsoft.AspNet.Mvc.Razor.Test/Compilation/CompilationResultTest.cs @@ -15,10 +15,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Test public void FailedResult_ThrowsWhenAccessingCompiledType() { // Arrange - var expected = -@"Compilation for 'myfile' failed: -hello -world"; + var expected = @"Error compiling page at 'myfile'."; var originalContent = "Original file content"; var fileInfo = new Mock(); fileInfo.SetupGet(f => f.PhysicalPath) @@ -28,8 +25,8 @@ world"; .Returns(new MemoryStream(contentBytes)); var messages = new[] { - new CompilationMessage("hello"), - new CompilationMessage("world") + new CompilationMessage("hello", 1, 1, 2, 2), + new CompilationMessage("world", 3, 3, 4, 3) }; var result = CompilationResult.Failed(fileInfo.Object, "

hello world

", @@ -38,7 +35,9 @@ world"; // Act and Assert var ex = Assert.Throws(() => result.CompiledType); Assert.Equal(expected, ex.Message); - Assert.Equal(originalContent, ex.FileContent); + var compilationFailure = Assert.Single(ex.CompilationFailures); + Assert.Equal(originalContent, compilationFailure.SourceFileContent); + Assert.Equal(messages, compilationFailure.Messages); } } } \ No newline at end of file diff --git a/test/Microsoft.AspNet.Mvc.Razor.Test/Compilation/RazorCompilationServiceTest.cs b/test/Microsoft.AspNet.Mvc.Razor.Test/Compilation/RazorCompilationServiceTest.cs index 38e9ecf27e..9cf4fb9899 100644 --- a/test/Microsoft.AspNet.Mvc.Razor.Test/Compilation/RazorCompilationServiceTest.cs +++ b/test/Microsoft.AspNet.Mvc.Razor.Test/Compilation/RazorCompilationServiceTest.cs @@ -73,7 +73,9 @@ namespace Microsoft.AspNet.Mvc.Razor.Test // Assert var ex = Assert.Throws(() => result.CompiledType); - Assert.Equal("some message", Assert.Single(ex.Messages).Message); + var failure = Assert.Single(ex.CompilationFailures); + var message = Assert.Single(failure.Messages); + Assert.Equal("some message", message.Message); host.Verify(); } diff --git a/test/WebSites/ErrorPageMiddlewareWebSite/ErrorPageMiddlewareController.cs b/test/WebSites/ErrorPageMiddlewareWebSite/ErrorPageMiddlewareController.cs new file mode 100644 index 0000000000..dda4e1f7a2 --- /dev/null +++ b/test/WebSites/ErrorPageMiddlewareWebSite/ErrorPageMiddlewareController.cs @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using Microsoft.AspNet.Mvc; + +namespace ErrorPageMiddlewareWebSite +{ + public class ErrorPageMiddlewareController : Controller + { + [HttpGet("/CompilationFailure")] + public IActionResult CompilationFailure() + { + return View(); + } + + [HttpGet("/ParserError")] + public IActionResult ParserError() + { + return View(); + } + } +} diff --git a/test/WebSites/ErrorPageMiddlewareWebSite/ErrorPageMiddlewareWebSite.kproj b/test/WebSites/ErrorPageMiddlewareWebSite/ErrorPageMiddlewareWebSite.kproj new file mode 100644 index 0000000000..8b6261cfdd --- /dev/null +++ b/test/WebSites/ErrorPageMiddlewareWebSite/ErrorPageMiddlewareWebSite.kproj @@ -0,0 +1,20 @@ + + + + 14.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + ad545a5b-2ba5-4314-88ac-fc2acf2cc718 + + + + + + + 2.0 + 6288 + + + \ No newline at end of file diff --git a/test/WebSites/ErrorPageMiddlewareWebSite/Startup.cs b/test/WebSites/ErrorPageMiddlewareWebSite/Startup.cs new file mode 100644 index 0000000000..dcc5c967eb --- /dev/null +++ b/test/WebSites/ErrorPageMiddlewareWebSite/Startup.cs @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using Microsoft.AspNet.Builder; +using Microsoft.Framework.DependencyInjection; + +namespace ErrorPageMiddlewareWebSite +{ + public class Startup + { + public void Configure(IApplicationBuilder app) + { + var configuration = app.GetTestConfiguration(); + + app.UseServices(services => + { + services.AddMvc(configuration); + }); + + app.UseErrorPage(); + app.UseMvc(); + } + } +} diff --git a/test/WebSites/ErrorPageMiddlewareWebSite/Views/ErrorPageMiddleware/CompilationFailure.cshtml b/test/WebSites/ErrorPageMiddlewareWebSite/Views/ErrorPageMiddleware/CompilationFailure.cshtml new file mode 100644 index 0000000000..8766bf1977 --- /dev/null +++ b/test/WebSites/ErrorPageMiddlewareWebSite/Views/ErrorPageMiddleware/CompilationFailure.cshtml @@ -0,0 +1,3 @@ +@{ + string x = 10; +} \ No newline at end of file diff --git a/test/WebSites/ErrorPageMiddlewareWebSite/Views/ErrorPageMiddleware/ParserError.cshtml b/test/WebSites/ErrorPageMiddlewareWebSite/Views/ErrorPageMiddleware/ParserError.cshtml new file mode 100644 index 0000000000..22c63d42a8 --- /dev/null +++ b/test/WebSites/ErrorPageMiddlewareWebSite/Views/ErrorPageMiddleware/ParserError.cshtml @@ -0,0 +1,4 @@ +@{ + +} + \ No newline at end of file diff --git a/test/WebSites/ErrorPageMiddlewareWebSite/project.json b/test/WebSites/ErrorPageMiddlewareWebSite/project.json new file mode 100644 index 0000000000..e9d3fb720a --- /dev/null +++ b/test/WebSites/ErrorPageMiddlewareWebSite/project.json @@ -0,0 +1,20 @@ +{ + "commands": { + "web": "Microsoft.AspNet.Hosting server=Microsoft.AspNet.Server.WebListener server.urls=http://localhost:5001", + "kestrel": "Microsoft.AspNet.Hosting --server Kestrel --server.urls http://localhost:5000" + }, + "dependencies": { + "Kestrel": "1.0.0-*", + "Microsoft.AspNet.Diagnostics": "1.0.0-*", + "Microsoft.AspNet.Mvc": "6.0.0-*", + "Microsoft.AspNet.Mvc.TestConfiguration": "1.0.0", + "Microsoft.AspNet.Server.IIS": "1.0.0-*", + "Microsoft.AspNet.Server.WebListener": "1.0.0-*", + "Microsoft.AspNet.StaticFiles": "1.0.0-*" + }, + "frameworks": { + "aspnet50": { }, + "aspnetcore50": { } + }, + "webroot": "wwwroot" +} diff --git a/test/WebSites/ErrorPageMiddlewareWebSite/wwwroot/README.md b/test/WebSites/ErrorPageMiddlewareWebSite/wwwroot/README.md new file mode 100644 index 0000000000..e69de29bb2