From e8503a6b3dd321815a1640bf1cb9197b9f8d2fb9 Mon Sep 17 00:00:00 2001 From: Thomas Ardal Date: Wed, 15 Nov 2023 10:32:12 +0100 Subject: [PATCH] Target newest Elmah.Io.Client prerelease and .NET 8 --- .github/workflows/dotnet-core.yml | 4 +- Elmah.Io.AspNetCore.sln | 16 ++-- .../Controllers/HomeController.cs | 45 --------- .../Models/ErrorViewModel.cs | 11 --- .../Elmah.Io.AspNetCore31.Example/Program.cs | 26 ------ .../Elmah.Io.AspNetCore31.Example/Startup.cs | 91 ------------------- .../Views/Home/Index.cshtml | 8 -- .../Views/_ViewImports.cshtml | 3 - .../appsettings.Development.json | 9 -- .../Elmah.Io.AspNetCore70.Example/Program.cs | 2 +- .../Elmah.Io.AspNetCore80.Example.csproj} | 4 +- .../Pages}/Error.cshtml | 5 +- .../Pages/Error.cshtml.cs | 28 ++++++ .../Pages/Index.cshtml | 10 ++ .../Pages/Index.cshtml.cs | 26 ++++++ .../Pages}/Privacy.cshtml | 4 +- .../Pages/Privacy.cshtml.cs | 32 +++++++ .../Pages}/Shared/_Layout.cshtml | 23 +++-- .../Pages/Shared/_Layout.cshtml.css | 48 ++++++++++ .../Shared/_ValidationScriptsPartial.cshtml | 0 .../Pages/_ViewImports.cshtml | 3 + .../Pages}/_ViewStart.cshtml | 0 .../Elmah.Io.AspNetCore80.Example/Program.cs | 67 ++++++++++++++ .../appsettings.Development.json | 9 ++ .../appsettings.json | 5 +- samples/README.md | 4 +- .../Elmah.Io.AspNetCore.HealthChecks.csproj | 2 +- .../Elmah.Io.AspNetCore.csproj | 6 +- .../Elmah.Io.AspNetCore.Tests.csproj | 2 +- 29 files changed, 265 insertions(+), 228 deletions(-) delete mode 100644 samples/Elmah.Io.AspNetCore31.Example/Controllers/HomeController.cs delete mode 100644 samples/Elmah.Io.AspNetCore31.Example/Models/ErrorViewModel.cs delete mode 100644 samples/Elmah.Io.AspNetCore31.Example/Program.cs delete mode 100644 samples/Elmah.Io.AspNetCore31.Example/Startup.cs delete mode 100644 samples/Elmah.Io.AspNetCore31.Example/Views/Home/Index.cshtml delete mode 100644 samples/Elmah.Io.AspNetCore31.Example/Views/_ViewImports.cshtml delete mode 100644 samples/Elmah.Io.AspNetCore31.Example/appsettings.Development.json rename samples/{Elmah.Io.AspNetCore31.Example/Elmah.Io.AspNetCore31.Example.csproj => Elmah.Io.AspNetCore80.Example/Elmah.Io.AspNetCore80.Example.csproj} (63%) rename samples/{Elmah.Io.AspNetCore31.Example/Views/Shared => Elmah.Io.AspNetCore80.Example/Pages}/Error.cshtml (82%) create mode 100644 samples/Elmah.Io.AspNetCore80.Example/Pages/Error.cshtml.cs create mode 100644 samples/Elmah.Io.AspNetCore80.Example/Pages/Index.cshtml create mode 100644 samples/Elmah.Io.AspNetCore80.Example/Pages/Index.cshtml.cs rename samples/{Elmah.Io.AspNetCore31.Example/Views/Home => Elmah.Io.AspNetCore80.Example/Pages}/Privacy.cshtml (80%) create mode 100644 samples/Elmah.Io.AspNetCore80.Example/Pages/Privacy.cshtml.cs rename samples/{Elmah.Io.AspNetCore31.Example/Views => Elmah.Io.AspNetCore80.Example/Pages}/Shared/_Layout.cshtml (68%) create mode 100644 samples/Elmah.Io.AspNetCore80.Example/Pages/Shared/_Layout.cshtml.css rename samples/{Elmah.Io.AspNetCore31.Example/Views => Elmah.Io.AspNetCore80.Example/Pages}/Shared/_ValidationScriptsPartial.cshtml (100%) create mode 100644 samples/Elmah.Io.AspNetCore80.Example/Pages/_ViewImports.cshtml rename samples/{Elmah.Io.AspNetCore31.Example/Views => Elmah.Io.AspNetCore80.Example/Pages}/_ViewStart.cshtml (100%) create mode 100644 samples/Elmah.Io.AspNetCore80.Example/Program.cs create mode 100644 samples/Elmah.Io.AspNetCore80.Example/appsettings.Development.json rename samples/{Elmah.Io.AspNetCore31.Example => Elmah.Io.AspNetCore80.Example}/appsettings.json (64%) diff --git a/.github/workflows/dotnet-core.yml b/.github/workflows/dotnet-core.yml index 800cf7a..379ce3c 100644 --- a/.github/workflows/dotnet-core.yml +++ b/.github/workflows/dotnet-core.yml @@ -12,15 +12,15 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup .NET uses: actions/setup-dotnet@v3 with: dotnet-version: | - 3.1.x 6.0.x 7.0.x + 8.0.x - name: Install dependencies run: dotnet restore diff --git a/Elmah.Io.AspNetCore.sln b/Elmah.Io.AspNetCore.sln index 503c44c..0dcdb01 100644 --- a/Elmah.Io.AspNetCore.sln +++ b/Elmah.Io.AspNetCore.sln @@ -28,11 +28,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elmah.Io.AspNetCore.Tests", EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elmah.Io.AspNetCore.HealthChecks.Example", "samples\Elmah.Io.AspNetCore.HealthChecks.Example\Elmah.Io.AspNetCore.HealthChecks.Example.csproj", "{A4DDFAB9-076D-4CA4-9A6E-EF5550605BD3}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elmah.Io.AspNetCore31.Example", "samples\Elmah.Io.AspNetCore31.Example\Elmah.Io.AspNetCore31.Example.csproj", "{6AF05883-55D8-4952-94E8-A5BF00F393A8}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elmah.Io.AspNetCore60.Example", "samples\Elmah.Io.AspNetCore60.Example\Elmah.Io.AspNetCore60.Example.csproj", "{44812DB3-4FAD-4BF4-83D6-0807886A042B}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elmah.Io.AspNetCore70.Example", "samples\Elmah.Io.AspNetCore70.Example\Elmah.Io.AspNetCore70.Example.csproj", "{C7C799CD-1C2A-4170-91B2-268060D99427}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elmah.Io.AspNetCore70.Example", "samples\Elmah.Io.AspNetCore70.Example\Elmah.Io.AspNetCore70.Example.csproj", "{C7C799CD-1C2A-4170-91B2-268060D99427}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elmah.Io.AspNetCore80.Example", "samples\Elmah.Io.AspNetCore80.Example\Elmah.Io.AspNetCore80.Example.csproj", "{96D3E57A-3734-4049-BAEA-E97A405AE4EE}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -60,10 +60,6 @@ Global {A4DDFAB9-076D-4CA4-9A6E-EF5550605BD3}.Debug|Any CPU.Build.0 = Debug|Any CPU {A4DDFAB9-076D-4CA4-9A6E-EF5550605BD3}.Release|Any CPU.ActiveCfg = Release|Any CPU {A4DDFAB9-076D-4CA4-9A6E-EF5550605BD3}.Release|Any CPU.Build.0 = Release|Any CPU - {6AF05883-55D8-4952-94E8-A5BF00F393A8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6AF05883-55D8-4952-94E8-A5BF00F393A8}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6AF05883-55D8-4952-94E8-A5BF00F393A8}.Release|Any CPU.ActiveCfg = Release|Any CPU - {6AF05883-55D8-4952-94E8-A5BF00F393A8}.Release|Any CPU.Build.0 = Release|Any CPU {44812DB3-4FAD-4BF4-83D6-0807886A042B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {44812DB3-4FAD-4BF4-83D6-0807886A042B}.Debug|Any CPU.Build.0 = Debug|Any CPU {44812DB3-4FAD-4BF4-83D6-0807886A042B}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -72,6 +68,10 @@ Global {C7C799CD-1C2A-4170-91B2-268060D99427}.Debug|Any CPU.Build.0 = Debug|Any CPU {C7C799CD-1C2A-4170-91B2-268060D99427}.Release|Any CPU.ActiveCfg = Release|Any CPU {C7C799CD-1C2A-4170-91B2-268060D99427}.Release|Any CPU.Build.0 = Release|Any CPU + {96D3E57A-3734-4049-BAEA-E97A405AE4EE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {96D3E57A-3734-4049-BAEA-E97A405AE4EE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {96D3E57A-3734-4049-BAEA-E97A405AE4EE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {96D3E57A-3734-4049-BAEA-E97A405AE4EE}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -82,9 +82,9 @@ Global {143AD06F-4F57-4E6B-9C09-A38005E5C025} = {B9EC1066-4F47-4310-9553-1298325321D8} {7F9CB9B1-BDB3-430B-84AF-0BCD8CE1C4F3} = {E0D4A60F-5411-4587-A085-D41117F83905} {A4DDFAB9-076D-4CA4-9A6E-EF5550605BD3} = {AEAB4533-28CE-4CA9-9CD7-FC7FEF911204} - {6AF05883-55D8-4952-94E8-A5BF00F393A8} = {AEAB4533-28CE-4CA9-9CD7-FC7FEF911204} {44812DB3-4FAD-4BF4-83D6-0807886A042B} = {AEAB4533-28CE-4CA9-9CD7-FC7FEF911204} {C7C799CD-1C2A-4170-91B2-268060D99427} = {AEAB4533-28CE-4CA9-9CD7-FC7FEF911204} + {96D3E57A-3734-4049-BAEA-E97A405AE4EE} = {AEAB4533-28CE-4CA9-9CD7-FC7FEF911204} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {DAE57CF5-2DDC-4EF5-85A3-BDA571A8E9A9} diff --git a/samples/Elmah.Io.AspNetCore31.Example/Controllers/HomeController.cs b/samples/Elmah.Io.AspNetCore31.Example/Controllers/HomeController.cs deleted file mode 100644 index 6af7300..0000000 --- a/samples/Elmah.Io.AspNetCore31.Example/Controllers/HomeController.cs +++ /dev/null @@ -1,45 +0,0 @@ -using Elmah.Io.AspNetCore; -using Elmah.Io.AspNetCore31.Example.Models; -using Microsoft.AspNetCore.Mvc; -using Microsoft.Extensions.Logging; -using System; -using System.Diagnostics; - -namespace Elmah.Io.AspNetCore31.Example.Controllers -{ - public class HomeController : Controller - { - private readonly ILogger _logger; - - public HomeController(ILogger logger) - { - _logger = logger; - } - - public IActionResult Index() - { - throw new Exception("Do you know what happened to the neanderthals, Bernard? We ate them."); - } - - public IActionResult Privacy() - { - try - { - var i = 0; - var result = 42 / i; - } - catch (DivideByZeroException e) - { - e.Ship(HttpContext); - } - - return View(); - } - - [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] - public IActionResult Error() - { - return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); - } - } -} diff --git a/samples/Elmah.Io.AspNetCore31.Example/Models/ErrorViewModel.cs b/samples/Elmah.Io.AspNetCore31.Example/Models/ErrorViewModel.cs deleted file mode 100644 index e86cf0e..0000000 --- a/samples/Elmah.Io.AspNetCore31.Example/Models/ErrorViewModel.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; - -namespace Elmah.Io.AspNetCore31.Example.Models -{ - public class ErrorViewModel - { - public string RequestId { get; set; } - - public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); - } -} diff --git a/samples/Elmah.Io.AspNetCore31.Example/Program.cs b/samples/Elmah.Io.AspNetCore31.Example/Program.cs deleted file mode 100644 index 97e3d48..0000000 --- a/samples/Elmah.Io.AspNetCore31.Example/Program.cs +++ /dev/null @@ -1,26 +0,0 @@ -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.Hosting; -using Microsoft.Extensions.Logging; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace Elmah.Io.AspNetCore31.Example -{ - public class Program - { - public static void Main(string[] args) - { - CreateHostBuilder(args).Build().Run(); - } - - public static IHostBuilder CreateHostBuilder(string[] args) => - Host.CreateDefaultBuilder(args) - .ConfigureWebHostDefaults(webBuilder => - { - webBuilder.UseStartup(); - }); - } -} diff --git a/samples/Elmah.Io.AspNetCore31.Example/Startup.cs b/samples/Elmah.Io.AspNetCore31.Example/Startup.cs deleted file mode 100644 index a4631b9..0000000 --- a/samples/Elmah.Io.AspNetCore31.Example/Startup.cs +++ /dev/null @@ -1,91 +0,0 @@ -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; -using System; -using System.Net; - -namespace Elmah.Io.AspNetCore31.Example -{ - public class Startup - { - public Startup(IConfiguration configuration) - { - Configuration = configuration; - } - - public IConfiguration Configuration { get; } - - // This method gets called by the runtime. Use this method to add services to the container. - public void ConfigureServices(IServiceCollection services) - { - // IMPORTANT: this is where the magic happens. Insert your api key found on the profile as well as the log id of the log to log to. - services.AddElmahIo(options => - { - options.ApiKey = "API_KEY"; - options.LogId = new Guid("LOG_ID"); - - // Optional application name - //options.Application = "ASP.NET Core 3.1 Application"; - - // Add event handlers etc. like this: - //options.OnMessage = msg => - //{ - // msg.Version = "3.1.0"; - //}; - - // Remove comment on the following line to log through a proxy (in this case Fiddler). - //options.WebProxy = new WebProxy("localhost", 8888); - }); - - // ApiKey and LogId can be configured in appsettings.json as well, by calling the Configure-method instead of AddElmahIo. - //services.Configure(Configuration.GetSection("ElmahIo")); - // Still need to call this to register all dependencies - //services.AddElmahIo(); - - // If you configure ApiKey and LogId through appsettings.json, you can still add event handlers, configure handled status codes, etc. - //services.Configure(o => - //{ - // o.OnMessage = msg => - // { - // msg.Version = "3.1.0"; - // }; - //}); - - services.AddControllersWithViews(); - } - - // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IWebHostEnvironment env) - { - if (env.IsDevelopment()) - { - app.UseDeveloperExceptionPage(); - } - else - { - app.UseExceptionHandler("/Home/Error"); - // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. - app.UseHsts(); - } - - // IMPORTANT: registers the elmah.io middleware (after registering other exception-aware middleware. - app.UseElmahIo(); - - app.UseHttpsRedirection(); - app.UseStaticFiles(); - - app.UseRouting(); - - app.UseAuthorization(); - - app.UseEndpoints(endpoints => - { - endpoints.MapControllerRoute( - name: "default", - pattern: "{controller=Home}/{action=Index}/{id?}"); - }); - } - } -} diff --git a/samples/Elmah.Io.AspNetCore31.Example/Views/Home/Index.cshtml b/samples/Elmah.Io.AspNetCore31.Example/Views/Home/Index.cshtml deleted file mode 100644 index d2d19bd..0000000 --- a/samples/Elmah.Io.AspNetCore31.Example/Views/Home/Index.cshtml +++ /dev/null @@ -1,8 +0,0 @@ -@{ - ViewData["Title"] = "Home Page"; -} - -
-

Welcome

-

Learn about building Web apps with ASP.NET Core.

-
diff --git a/samples/Elmah.Io.AspNetCore31.Example/Views/_ViewImports.cshtml b/samples/Elmah.Io.AspNetCore31.Example/Views/_ViewImports.cshtml deleted file mode 100644 index 5a4d456..0000000 --- a/samples/Elmah.Io.AspNetCore31.Example/Views/_ViewImports.cshtml +++ /dev/null @@ -1,3 +0,0 @@ -@using Elmah.Io.AspNetCore31.Example -@using Elmah.Io.AspNetCore31.Example.Models -@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers diff --git a/samples/Elmah.Io.AspNetCore31.Example/appsettings.Development.json b/samples/Elmah.Io.AspNetCore31.Example/appsettings.Development.json deleted file mode 100644 index 8983e0f..0000000 --- a/samples/Elmah.Io.AspNetCore31.Example/appsettings.Development.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft": "Warning", - "Microsoft.Hosting.Lifetime": "Information" - } - } -} diff --git a/samples/Elmah.Io.AspNetCore70.Example/Program.cs b/samples/Elmah.Io.AspNetCore70.Example/Program.cs index 8df6235..8efd78e 100644 --- a/samples/Elmah.Io.AspNetCore70.Example/Program.cs +++ b/samples/Elmah.Io.AspNetCore70.Example/Program.cs @@ -35,7 +35,7 @@ //{ // o.OnMessage = msg => // { -// msg.Version = "6.0.0"; +// msg.Version = "7.0.0"; // }; //}); diff --git a/samples/Elmah.Io.AspNetCore31.Example/Elmah.Io.AspNetCore31.Example.csproj b/samples/Elmah.Io.AspNetCore80.Example/Elmah.Io.AspNetCore80.Example.csproj similarity index 63% rename from samples/Elmah.Io.AspNetCore31.Example/Elmah.Io.AspNetCore31.Example.csproj rename to samples/Elmah.Io.AspNetCore80.Example/Elmah.Io.AspNetCore80.Example.csproj index d3ee986..085fab9 100644 --- a/samples/Elmah.Io.AspNetCore31.Example/Elmah.Io.AspNetCore31.Example.csproj +++ b/samples/Elmah.Io.AspNetCore80.Example/Elmah.Io.AspNetCore80.Example.csproj @@ -1,7 +1,9 @@ - netcoreapp3.1 + net8.0 + enable + enable diff --git a/samples/Elmah.Io.AspNetCore31.Example/Views/Shared/Error.cshtml b/samples/Elmah.Io.AspNetCore80.Example/Pages/Error.cshtml similarity index 82% rename from samples/Elmah.Io.AspNetCore31.Example/Views/Shared/Error.cshtml rename to samples/Elmah.Io.AspNetCore80.Example/Pages/Error.cshtml index a1e0478..6f92b95 100644 --- a/samples/Elmah.Io.AspNetCore31.Example/Views/Shared/Error.cshtml +++ b/samples/Elmah.Io.AspNetCore80.Example/Pages/Error.cshtml @@ -1,4 +1,5 @@ -@model ErrorViewModel +@page +@model ErrorModel @{ ViewData["Title"] = "Error"; } @@ -15,7 +16,7 @@

Development Mode

- Swapping to Development environment will display more detailed information about the error that occurred. + Swapping to the Development environment displays detailed information about the error that occurred.

The Development environment shouldn't be enabled for deployed applications. diff --git a/samples/Elmah.Io.AspNetCore80.Example/Pages/Error.cshtml.cs b/samples/Elmah.Io.AspNetCore80.Example/Pages/Error.cshtml.cs new file mode 100644 index 0000000..ca59f45 --- /dev/null +++ b/samples/Elmah.Io.AspNetCore80.Example/Pages/Error.cshtml.cs @@ -0,0 +1,28 @@ +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.RazorPages; +using System.Diagnostics; + +namespace Elmah.Io.AspNetCore80.Example.Pages +{ + [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] + [IgnoreAntiforgeryToken] + public class ErrorModel : PageModel + { + public string? RequestId { get; set; } + + public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); + + private readonly ILogger _logger; + + public ErrorModel(ILogger logger) + { + _logger = logger; + } + + public void OnGet() + { + RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier; + } + } + +} diff --git a/samples/Elmah.Io.AspNetCore80.Example/Pages/Index.cshtml b/samples/Elmah.Io.AspNetCore80.Example/Pages/Index.cshtml new file mode 100644 index 0000000..f9ff8d4 --- /dev/null +++ b/samples/Elmah.Io.AspNetCore80.Example/Pages/Index.cshtml @@ -0,0 +1,10 @@ +@page +@model IndexModel +@{ + ViewData["Title"] = "Home page"; +} + +

+

Welcome

+

Learn about building Web apps with ASP.NET Core.

+
diff --git a/samples/Elmah.Io.AspNetCore80.Example/Pages/Index.cshtml.cs b/samples/Elmah.Io.AspNetCore80.Example/Pages/Index.cshtml.cs new file mode 100644 index 0000000..e1671a0 --- /dev/null +++ b/samples/Elmah.Io.AspNetCore80.Example/Pages/Index.cshtml.cs @@ -0,0 +1,26 @@ +using Elmah.Io.AspNetCore; +using Microsoft.AspNetCore.Mvc.RazorPages; + +namespace Elmah.Io.AspNetCore80.Example.Pages +{ + public class IndexModel : PageModel + { + private readonly ILogger _logger; + + public IndexModel(ILogger logger) + { + _logger = logger; + } + + public void OnGet() + { + // Logging can be used for breadcrumbs + _logger.LogInformation("Requesting the frontpage"); + + // Breadcrumbs can also be added manually + //ElmahIoApi.AddBreadcrumb(new Client.Breadcrumb(action: "Navigation", message: "Requesting the frontpage"), HttpContext); + + throw new Exception("Do you know what happened to the neanderthals, Bernard? We ate them."); + } + } +} diff --git a/samples/Elmah.Io.AspNetCore31.Example/Views/Home/Privacy.cshtml b/samples/Elmah.Io.AspNetCore80.Example/Pages/Privacy.cshtml similarity index 80% rename from samples/Elmah.Io.AspNetCore31.Example/Views/Home/Privacy.cshtml rename to samples/Elmah.Io.AspNetCore80.Example/Pages/Privacy.cshtml index af4fb19..46ba966 100644 --- a/samples/Elmah.Io.AspNetCore31.Example/Views/Home/Privacy.cshtml +++ b/samples/Elmah.Io.AspNetCore80.Example/Pages/Privacy.cshtml @@ -1,4 +1,6 @@ -@{ +@page +@model PrivacyModel +@{ ViewData["Title"] = "Privacy Policy"; }

@ViewData["Title"]

diff --git a/samples/Elmah.Io.AspNetCore80.Example/Pages/Privacy.cshtml.cs b/samples/Elmah.Io.AspNetCore80.Example/Pages/Privacy.cshtml.cs new file mode 100644 index 0000000..1c26a3a --- /dev/null +++ b/samples/Elmah.Io.AspNetCore80.Example/Pages/Privacy.cshtml.cs @@ -0,0 +1,32 @@ +using Elmah.Io.AspNetCore; +using Microsoft.AspNetCore.Mvc.RazorPages; + +namespace Elmah.Io.AspNetCore80.Example.Pages +{ + public class PrivacyModel : PageModel + { + private readonly ILogger _logger; + + public PrivacyModel(ILogger logger) + { + _logger = logger; + } + + public void OnGet() + { + try + { + var i = 0; + var result = 42 / i; + } + catch (DivideByZeroException e) + { + e.Ship(HttpContext); + + // Or the Log method on ElmahIoApi + //ElmahIoApi.Log(e, HttpContext); + } + } + } + +} diff --git a/samples/Elmah.Io.AspNetCore31.Example/Views/Shared/_Layout.cshtml b/samples/Elmah.Io.AspNetCore80.Example/Pages/Shared/_Layout.cshtml similarity index 68% rename from samples/Elmah.Io.AspNetCore31.Example/Views/Shared/_Layout.cshtml rename to samples/Elmah.Io.AspNetCore80.Example/Pages/Shared/_Layout.cshtml index 70d1ed1..5bb7d74 100644 --- a/samples/Elmah.Io.AspNetCore31.Example/Views/Shared/_Layout.cshtml +++ b/samples/Elmah.Io.AspNetCore80.Example/Pages/Shared/_Layout.cshtml @@ -3,26 +3,27 @@ - @ViewData["Title"] - Elmah.Io.AspNetCore31.Example + @ViewData["Title"] - Elmah.Io.AspNetCore80.Example - + +