-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherror.aspx
More file actions
44 lines (44 loc) · 1.66 KB
/
error.aspx
File metadata and controls
44 lines (44 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<%@ Page Title="" Language="C#" MasterPageFile="~/MainLayout.Master" AutoEventWireup="true" CodeBehind="error.aspx.cs" Inherits="Bookstore.error" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MASTERHEAD" runat="server">
<style>
.centered {
height: 100%;
display: flex;
justify-content: center;
align-items: center;
font-size: 2rem;
color: #333;
}
</style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MASTERCONTENT" runat="server">
<div class="centered" id="errorMessage">Unknown error</div>
<script>
function getErrorMessageFromUrl() {
const params = new URLSearchParams(window.location.search);
const errorCode = params.get('error');
let message = 'Unknown error';
switch(errorCode) {
case '404':
message = 'Page not found (404)';
break;
case '500':
message = 'Internal server error (500)';
break;
case '403':
message = 'Access forbidden (403)';
break;
case '400':
message = 'Bad request (400)';
break;
default:
if (errorCode) {
message = `Error code: ${errorCode}`;
}
break;
}
return message;
}
document.getElementById('errorMessage').textContent = getErrorMessageFromUrl();
</script>
</asp:Content>