Skip to content

Commit 0c32269

Browse files
committed
Unified Exception Handling between Admin and Customer Portals to error message underneath the Login Button.
1 parent 0c699e1 commit 0c32269

File tree

5 files changed

+145
-4
lines changed

5 files changed

+145
-4
lines changed

WebApplication2/Customer/Pages/login.aspx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@
8585
text-decoration: underline;
8686
}
8787
88+
.error-message {
89+
color: #6a11cb;
90+
font-size: 14px;
91+
margin-top: 10px;
92+
}
93+
8894
.customer-login-link {
8995
margin-top: 10px;
9096
font-size: 17px;
@@ -115,6 +121,9 @@
115121
<asp:Button ID="buttonlogin" runat="server" onclick="loginm" Text="Login" CssClass="login-button" />
116122
</div>
117123
<br />
124+
<div>
125+
<asp:Label ID="lblError" runat="server" CssClass="error-message"></asp:Label>
126+
</div>
118127
<div class="customer-login-link">
119128
Are you an admin? <a href="/Pages/Login/Login.aspx">Go to admin login</a>
120129
</form>

WebApplication2/Customer/Pages/login.aspx.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ protected void loginm(object sender, EventArgs e)
4040
// Validate inputs
4141
if (string.IsNullOrEmpty(accountmn) || string.IsNullOrEmpty(pass))
4242
{
43-
Response.Write("<script>alert('Please fill in all fields.');</script>");
43+
lblError.Text = "Empty Fields found. Please fill in all fields.";
44+
password.Text = "";
4445
return;
4546
}
4647

@@ -74,8 +75,8 @@ protected void loginm(object sender, EventArgs e)
7475
}
7576
else
7677
{
77-
// Login failed
78-
Response.Write("<script>alert('Invalid mobile number or password.');</script>");
78+
lblError.Text = "These are invalid customer credentials. Please try again.";
79+
password.Text = "";
7980
}
8081
}
8182
catch (Exception ex)

WebApplication2/Customer/Pages/login.aspx.designer.cs

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

WebApplication2/Pages/Login/Login.aspx.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,16 @@ protected void LoginButton(object sender, EventArgs e)
2323
}
2424
else
2525
{
26-
lblError.Text = "These are not valid admin credentials. Please try again.";
26+
if (string.IsNullOrEmpty(txtUsername.Value) || string.IsNullOrEmpty(txtPassword.Value))
27+
{
28+
lblError.Text = "Empty Fields found. Please fill in all fields.";
29+
txtPassword.Value = "";
30+
return;
31+
}
32+
else
33+
{
34+
lblError.Text = "These are invalid admin credentials. Please try again.";
35+
}
2736
}
2837
}
2938
}
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
{
2+
"$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#",
3+
"contentVersion": "1.0.0.0",
4+
"metadata": {
5+
"_dependencyType": "compute.appService.windows"
6+
},
7+
"parameters": {
8+
"resourceGroupName": {
9+
"type": "string",
10+
"defaultValue": "TelecomAppRG",
11+
"metadata": {
12+
"description": "Name of the resource group for the resource. It is recommended to put resources under same resource group for better tracking."
13+
}
14+
},
15+
"resourceGroupLocation": {
16+
"type": "string",
17+
"defaultValue": "germanywestcentral",
18+
"metadata": {
19+
"description": "Location of the resource group. Resource groups could have different location than resources, however by default we use API versions from latest hybrid profile which support all locations for resource types we support."
20+
}
21+
},
22+
"resourceName": {
23+
"type": "string",
24+
"defaultValue": "telecom-customer-app",
25+
"metadata": {
26+
"description": "Name of the main resource to be created by this template."
27+
}
28+
},
29+
"resourceLocation": {
30+
"type": "string",
31+
"defaultValue": "[parameters('resourceGroupLocation')]",
32+
"metadata": {
33+
"description": "Location of the resource. By default use resource group's location, unless the resource provider is not supported there."
34+
}
35+
}
36+
},
37+
"variables": {
38+
"appServicePlan_name": "[concat('Plan', uniqueString(concat(parameters('resourceName'), subscription().subscriptionId)))]",
39+
"appServicePlan_ResourceId": "[concat('/subscriptions/', subscription().subscriptionId, '/resourceGroups/', parameters('resourceGroupName'), '/providers/Microsoft.Web/serverFarms/', variables('appServicePlan_name'))]"
40+
},
41+
"resources": [
42+
{
43+
"type": "Microsoft.Resources/resourceGroups",
44+
"name": "[parameters('resourceGroupName')]",
45+
"location": "[parameters('resourceGroupLocation')]",
46+
"apiVersion": "2019-10-01"
47+
},
48+
{
49+
"type": "Microsoft.Resources/deployments",
50+
"name": "[concat(parameters('resourceGroupName'), 'Deployment', uniqueString(concat(parameters('resourceName'), subscription().subscriptionId)))]",
51+
"resourceGroup": "[parameters('resourceGroupName')]",
52+
"apiVersion": "2019-10-01",
53+
"dependsOn": [
54+
"[parameters('resourceGroupName')]"
55+
],
56+
"properties": {
57+
"mode": "Incremental",
58+
"template": {
59+
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
60+
"contentVersion": "1.0.0.0",
61+
"resources": [
62+
{
63+
"location": "[parameters('resourceLocation')]",
64+
"name": "[parameters('resourceName')]",
65+
"type": "Microsoft.Web/sites",
66+
"apiVersion": "2015-08-01",
67+
"tags": {
68+
"[concat('hidden-related:', variables('appServicePlan_ResourceId'))]": "empty"
69+
},
70+
"dependsOn": [
71+
"[variables('appServicePlan_ResourceId')]"
72+
],
73+
"kind": "app",
74+
"properties": {
75+
"name": "[parameters('resourceName')]",
76+
"kind": "app",
77+
"httpsOnly": true,
78+
"reserved": false,
79+
"serverFarmId": "[variables('appServicePlan_ResourceId')]",
80+
"siteConfig": {
81+
"metadata": [
82+
{
83+
"name": "CURRENT_STACK",
84+
"value": "dotnetcore"
85+
}
86+
]
87+
}
88+
},
89+
"identity": {
90+
"type": "SystemAssigned"
91+
}
92+
},
93+
{
94+
"location": "[parameters('resourceLocation')]",
95+
"name": "[variables('appServicePlan_name')]",
96+
"type": "Microsoft.Web/serverFarms",
97+
"apiVersion": "2015-08-01",
98+
"sku": {
99+
"name": "S1",
100+
"tier": "Standard",
101+
"family": "S",
102+
"size": "S1"
103+
},
104+
"properties": {
105+
"name": "[variables('appServicePlan_name')]"
106+
}
107+
}
108+
]
109+
}
110+
}
111+
}
112+
]
113+
}

0 commit comments

Comments
 (0)