TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Nirupa
NA
19
711
How to display en error message as "User Already exist" .
Apr 6 2016 7:31 AM
I have followed your below link ...please help me out i have use same code
http://www.c-sharpcorner.com/UploadFile/145c93/save-password-using-salted-hashing/
But the error message in not displaying
public class AdminController : Controller
{
// GET: Admin
public ActionResult Index()
{
return View();
}
// GET: Admin/Details/5
public ActionResult Registration()
{
return View();
}
[ValidateAntiForgeryToken]
[HttpPost]
public ActionResult Registration(User objNewUser)
{
try
{
using (var context = new CmsDbContext())
{
var chkUser = (from s in context.ObjRegisterUser where s.UserName == objNewUser.UserName || s.EmailId == objNewUser.EmailId select s).FirstOrDefault();
if (chkUser == null)
{
var keyNew = Helper.GeneratePassword(10);
var password = Helper.EncodePassword(objNewUser.Password, keyNew);
objNewUser.Password = password;
objNewUser.CreateDate = DateTime.Now;
objNewUser.ModifyDate = DateTime.Now;
objNewUser.VCode = keyNew;
context.ObjRegisterUser.Add(objNewUser);
context.SaveChanges();
ModelState.Clear();
return RedirectToAction("LogIn", "Login");
}
ViewBag.ErrorMessage = "User Allredy Exixts!!!!!!!!!!";//---this message is not displaying---//
return View();
}
}
catch (Exception e)
{
ViewBag.ErrorMessage = "Some exception occured" + e;
return View();
Thanks Inadvance
Reply
Answers (
2
)
.xls excel file not inserted all rows in database
Hi to all, how to send sms to mobile from asp.net web app