0% found this document useful (0 votes)
7 views

Special Task List

1. The document provides two programming exercises. The first asks to write a program to upload an Excel file, read data from it (including employee name, contact number, address, gender, education), and store it in a database. The second asks to create two web pages - one for user password policy configuration and one for user registration that applies the configured password policy for validation. 2. Code examples are provided to define a Policy class for the password requirements and basic MVC code for the two web pages - one to set the policy and one for user registration that validates the password against the policy. 3. The document outlines the requirements but does not provide a full solution to the exercises. It focuses on getting
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Special Task List

1. The document provides two programming exercises. The first asks to write a program to upload an Excel file, read data from it (including employee name, contact number, address, gender, education), and store it in a database. The second asks to create two web pages - one for user password policy configuration and one for user registration that applies the configured password policy for validation. 2. Code examples are provided to define a Policy class for the password requirements and basic MVC code for the two web pages - one to set the policy and one for user registration that validates the password against the policy. 3. The document outlines the requirements but does not provide a full solution to the exercises. It focuses on getting
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

Marwadi University

Faculty of Engineering and Technology


Department of Information and Communication
Technology
Subject: .NET Technology
(01CT1518)
Date: 05/11/2023 Enrolment No: 92100133031

Special exercises :

1. Write a program to allow user to upload Excel file and read data from excel and store it
into database, columns are as follows.

EmployeeName ContactNumer Address Gender Education

Note : Required tables to be created with your wisdom.

2. Write a program which has 2 pages as follows :

A) Page for User Password policy configuration

B) User registration page with password policy restriction

I.e. 2 lowercase, 1 upercase, 1 numeric, 2 special character etc where number should be
choose by user.

Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace WebApplication2.Controllers
{
public class Policy
{
public int minlen { get; set; }
public int uppercase { get; set; }
public int lowercase { get; set; }
public int numeric { get; set; }
public int sp_char { get; set; }
}
}
Password.cshtml:
@{
Layout = "~/Views/Shared/_Layout.cshtml";
}
@{
ViewBag.Title = "Password";
}
<h2></h2>
<!DOCTYPE html>
<html>
<head>
Marwadi University
Faculty of Engineering and Technology
Department of Information and Communication
Technology
Subject: .NET Technology
(01CT1518)
Date: 05/11/2023 Enrolment No: 92100133031

<meta name="viewport" content="width=device-width" />


<title>Password</title>
</head>
<body>
@using (Html.BeginForm())
{
<div class="form-horizontal">
<div class="form-group">
<label class="control-label col-md-2">Password</label>
<input type="password" name="Pwd" class="form-control" />
</div>
<p class="Error"> @ViewBag.errormsg </p>
<div class="form-group">
<br />
<p>
<input type="submit" value="Send" class="form-control" />
</p>
</div>
</div>
}
</body>
</html>
Indec.cshtml:
@model WebApplication2.Controllers.Policy
@{
ViewBag.Title = "Index";
}
<h2>Index</h2>
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()

<div class="form-horizontal">
<h4>Policy</h4>
<hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="form-group">
@Html.LabelFor(model => model.minlen, htmlAttributes: new
{@class ="control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.minlen, new
{
htmlAttributes = new
{
@class = "form-control"
}
})
@Html.ValidationMessageFor(model => model.minlen, "", new
{
@class =
"text-danger"
})
</div>
Marwadi University
Faculty of Engineering and Technology
Department of Information and Communication
Technology
Subject: .NET Technology
(01CT1518)
Date: 05/11/2023 Enrolment No: 92100133031

</div>
<div class="form-group">
@Html.LabelFor(model => model.uppercase, htmlAttributes: new
{
@class =
"control-label col-md-2"
})
<div class="col-md-10">
@Html.EditorFor(model => model.uppercase, new
{
htmlAttributes = new
{
@class = "form-control"
}
})
@Html.ValidationMessageFor(model => model.uppercase, "", new
{
@class
= "text-danger"
})
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.lowercase, htmlAttributes: new
{
@class =
"control-label col-md-2"
})
<div class="col-md-10">
@Html.EditorFor(model => model.lowercase, new
{
htmlAttributes = new
{
@class = "form-control"
}
})
@Html.ValidationMessageFor(model => model.lowercase, "", new
{
@class
= "text-danger"
})
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.numeric, htmlAttributes: new
{
@class =
"control-label col-md-2"
})
<div class="col-md-10">
@Html.EditorFor(model => model.numeric, new
{
htmlAttributes = new
Marwadi University
Faculty of Engineering and Technology
Department of Information and Communication
Technology
Subject: .NET Technology
(01CT1518)
Date: 05/11/2023 Enrolment No: 92100133031

{
@class = "form-control"
}
})
@Html.ValidationMessageFor(model => model.numeric, "", new
{
@class =
"text-danger"
})
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.sp_char, htmlAttributes: new
{
@class =
"control-label col-md-2"
})
<div class="col-md-10">
@Html.EditorFor(model => model.sp_char, new
{
htmlAttributes = new
{
@class = "form-control"
}
})
@Html.ValidationMessageFor(model => model.sp_char, "", new
{
@class =
"text-danger"
})
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Create" class="btn btn-default" />
</div>
</div>
</div>
}
@*<div>
@Html.ActionLink("Back to List", "Index")
</div>*@
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}
HomeController.cs:
using WebApplication2.Controllers;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace WebApplication2.Controllers
Marwadi University
Faculty of Engineering and Technology
Department of Information and Communication
Technology
Subject: .NET Technology
(01CT1518)
Date: 05/11/2023 Enrolment No: 92100133031

{
public class HomeController : Controller
{
static Policy Policy = new Policy();
public ActionResult Index()
{
return View();
}
[HttpPost]
public ActionResult Index(int minLen, int uppercase, int lowercase, int
numeric, int sp_char)
{
Policy.minlen = minLen;
Policy.uppercase = uppercase;
Policy.lowercase = lowercase;
Policy.numeric = numeric;
Policy.sp_char = sp_char;
return RedirectToAction("Password");
}
public ActionResult Password()
{
return View();
}
[HttpPost]
public ActionResult Password(string Pwd)
{
String errmsg = "Passwors is according to the policy";
int uppercase = 0;
int lowercase = 0;
int sp_char = 0;
int numeric = 0;
if (Pwd.Length < Policy.minlen)
{
errmsg = "Please setisfy the minimum length of the password which is "
+ Policy.minlen;
}
for (int i = 0; i < Pwd.Length; i++)
{
if (Pwd[i] >= 65 && Pwd[i] <= 90) uppercase++;
else if (Pwd[i] >= 97 && Pwd[i] <= 122) lowercase++;
else if (Pwd[i] >= 48 && Pwd[i] <= 57) numeric++;
else sp_char++;
}
if (lowercase < Policy.lowercase ||
uppercase < Policy.uppercase || numeric < Policy.numeric ||
sp_char < Policy.sp_char)
{
errmsg = "Password is not according to the enterd policy";
}
ViewBag.errormsg = errmsg;
return View();
}
public ActionResult About()
Marwadi University
Faculty of Engineering and Technology
Department of Information and Communication
Technology
Subject: .NET Technology
(01CT1518)
Date: 05/11/2023 Enrolment No: 92100133031

{
ViewBag.Message = "Your application description page.";
return View();
}
public ActionResult Contact()
{
ViewBag.Message = "Your contact page.";
return View();
}
}
}

3. Write a program to allow user to login with Google authenticator OTP code.
HomeController.cs:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace SpecialTaslThree.Controllers
{
[Authorize]
public class HomeController : Controller
{
public ActionResult Index()
{
return View();
}
public ActionResult About()
{
ViewBag.Message = "Your application description page.";
return View();
}
public ActionResult Contact()
{
ViewBag.Message = "Your contact page.";
return View();
}
}
}

Index.cshtml:

@model Webapplication2.Models.Login
@{
/**/
ViewBag.Title = "Login";
}
< h2 > Login </ h2 >
@if(ViewBag.Status == null || !ViewBag.Status)
Marwadi University
Faculty of Engineering and Technology
Department of Information and Communication
Technology
Subject: .NET Technology
(01CT1518)
Date: 05/11/2023 Enrolment No: 92100133031

{
< div > @ViewBag.Message </ div >
< div >
@using(Html.BeginForm())
{
@Html.AntiForgeryToken()
< div class= "form-horizontal" >

< h4 > Login </ h4 >

< hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
< div class= "form-group" >
@Html.LabelFor(model => model.UserName, htmlAttributes: new
{
@class = "control-label col-md-2"
})
< div class= "col-md-10" >
@Html.EditorFor(model => model.UserName, new
{
htmlAttributes
= new { @class = "form-control" }
})
@Html.ValidationMessageFor(model => model.UserName, "", new
{
@class = "text-danger"
})
</ div >
</ div >
< div class= "form-group" >
@Html.LabelFor(model => model.Password, htmlAttributes: new
{
@class = "control-label col-md-2"
})
< div class= "col-md-10" >
@Html.EditorFor(model => model.Password, new
{
htmlAttributes
= new { @class = "form-control" }
})
@Html.ValidationMessageFor(model => model.Password, "", new
{
@class = "text-danger"
})
</ div >
</ div >
< div class= "form-group" >

< div class= "col-md-offset-2 col-md-10" >

< input type = "submit" value = "Create" class= "btn btn-default" />

</ div >


Marwadi University
Faculty of Engineering and Technology
Department of Information and Communication
Technology
Subject: .NET Technology
(01CT1518)
Date: 05/11/2023 Enrolment No: 92100133031

</ div >

</ div >


}
</ div >
}
else
{
< div > @ViewBag.Message </ div >
< div >
< img src = "@ViewBag.BarcodeImageUrl" />

</ div >

< div >


Manual Setup Code : @ViewBag.SetupCode
</ div >

< div >


@using(Html.BeginForm("TwoFactorAuthenticate", "Login", FormMethod.Post))
{
< input type = "text" name = "CodeDigit" />

< input type = "submit" class= "btn btn-success" />


}
</ div >
}
< div >
@Html.ActionLink("Back to List", "Index")
</ div >
@section Scripts
{
@Scripts.Render("~/bundles/jqueryval")
}

UserProfile.cshtml:
@{
ViewBag.Title = "UserProfile";
}
< h2 > UserProfile </ h2 >
< h3 > @ViewBag.Message </ h3 >

You might also like