+ Request ID: @Model.RequestId
+
+ Swapping to the Development environment displays detailed information about the error that occurred. +
++ The Development environment shouldn't be enabled for deployed applications. + It can result in displaying sensitive information from exceptions to end users. + For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development + and restarting the app. +
diff --git a/netcore/AspNetCore GeodeSession Sample/Pages/Error.cshtml.cs b/netcore/AspNetCore GeodeSession Sample/Pages/Error.cshtml.cs new file mode 100644 index 0000000000..b6245b6337 --- /dev/null +++ b/netcore/AspNetCore GeodeSession Sample/Pages/Error.cshtml.cs @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.RazorPages; + +namespace SessionSample.Pages { + [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] + public class ErrorModel : PageModel { + public string RequestId { get; set; } + + public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); + + public void OnGet() { + RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier; + } + } +} diff --git a/netcore/AspNetCore GeodeSession Sample/Pages/Index.cshtml b/netcore/AspNetCore GeodeSession Sample/Pages/Index.cshtml new file mode 100644 index 0000000000..47bcf75bb8 --- /dev/null +++ b/netcore/AspNetCore GeodeSession Sample/Pages/Index.cshtml @@ -0,0 +1,99 @@ +@* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +*@ +@page +@using Microsoft.AspNetCore.Http +@model IndexModel +@{ + ViewData["Title"] = "Asp.Net Core Session Sample"; +} + +
+ The middleware value is set into the HttpContext.Items
collection by
+ the HttpContextItemsMiddleware
before Razor Pages processes the request.
+ The value is retreived by the page and displayed.
+
Value: @Model.SessionInfo_MiddlewareValue
+