HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
Controller
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- using System.Configuration;
- using System.Web.Security;
- using MySql.Data.MySqlClient;
- using NewProject160518.Models;
- namespace NewProject160518.Controllers
- {
- public class HomeController : Controller
- {
- // GET: Home
- string constr = ConfigurationManager.ConnectionStrings["con"].ConnectionString;
- [Authorize]
- public ActionResult Index()
- {
- return View();
- }
- [HttpGet]
- public ActionResult UserLogin()
- {
- return View();
- }
- [HttpPost]
- public ActionResult UserLogin(userlist userlist)
- {
- MySqlDataReader rd;
- MySqlConnection con = new MySqlConnection(constr);
- con.Open();
- string Query = "SELECT * FROM userlist where Emailid='"+userlist.Emailid+"' and Password ='"+ userlist.Password+"'";
- MySqlCommand cmd = new MySqlCommand(Query, con);
- rd = cmd.ExecuteReader();
- while (rd.Read())
- {
- if (rd.HasRows)
- {
- ViewData["Message"] = "Welcome !! "+userlist.Emailid +"";
- return RedirectToAction("index");
- break;
- }
- //else
- //{
- // Response.Write("");
- //}
- }
- return View();
- }
- [Authorize]
- [HttpPost]
- public ActionResult Logout()
- {
- FormsAuthentication.SignOut();
- //return View();
- return RedirectToAction("UserLogin");
- }
- }
- }
UserLogin.cshtml
- @model NewProject160518.Models.userlist
- @{
- ViewBag.Title = "UserLogin";
- }
User Login
- @using (Html.BeginForm())
- {
- @Html.AntiForgeryToken()
- class="form-horizontal">
- @Html.ValidationSummary(true, "", new { @class = "text-danger" })
class="form-group">- @Html.LabelFor(model => model.Emailid, htmlAttributes: new { @class = "control-label col-md-2" })
class="col-md-10">- @Html.EditorFor(model => model.Emailid, new { htmlAttributes = new { @class = "form-control" } })
- @Html.ValidationMessageFor(model => model.Emailid, "", new { @class = "text-danger" })
class="form-group">- @Html.LabelFor(model => model.Password, htmlAttributes: new { @class = "control-label col-md-2" })
class="col-md-10">- @Html.EditorFor(model => model.Password, new { htmlAttributes = new { @class = "form-control" } })
- @Html.ValidationMessageFor(model => model.Password, "", new { @class = "text-danger" })
class="form-group">class="col-md-offset-2 col-md-10">- "submit" value="Create" class="btn btn-default" />
- @ViewData["Message"]
- }
- @Html.ActionLink("Back to List", "Index")
Index.cshtml
- @{
- ViewBag.Title = "Index";
- }
Index
- Welcome @HttpContext.Current.User.Identity.Name
- @if (Request.IsAuthenticated)
- {
- using (Html.BeginForm("Logout","Home", FormMethod.Post, new { id="logoutForm"}))
- {
- "javascript:document.getElementById('logoutForm').submit()">Logout
- }
- }
Guest UserPosted May 17, 2018, 4:47 AM
Nanddeep NachanPosted May 17, 2018, 1:32 AM