Я хочу получить и отредактировать сведения о текущем вошедшем в систему пользователе в MVC
пока я пытаюсь это сделать, я получаю следующую ошибку :
Цитата:Текущий запрос на действие "edit" для контроллера типа "AccountController" неоднозначен между следующими методами действия: System.Web.Mvc.ActionResult edit() для типа WEBpass.Контроллеры.AccountController System. Web.Mvc.ActionResult Edit(Int32, WEBpass.Models.tbl_user) по типу EBpass.Контроллеры.AccountController
вот мой хранящей :-
//------------------------------------------------------------------------------ // <auto-generated> // This code was generated from a template. // // Manual changes to this file may cause unexpected behavior in your application. // Manual changes to this file will be overwritten if the code is regenerated. // </auto-generated> //------------------------------------------------------------------------------ namespace EBpass.Models { using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; public partial class tbl_user { [Key] public int User_id { get; set; } [Required] public string UserName { get; set; } [Required] public string FIrstName { get; set; } [Required] public string MiddleName { get; set; } [Required] public string LastName { get; set; } [Required] public string Gender { get; set; } public byte[] Profile { get; set; } [EmailAddress] public string EmailID { get; set; } [Required] public string State { get; set; } [Required] public string City { get; set; } [Required] public string Address { get; set; } [Required] public decimal Pincode { get; set; } [RegularExpression(@"(?<!\d)\d{10}(?!\d)",ErrorMessage ="please Give correct mobile number")] [Required] public decimal MoBileNo { get; set; } [DataType(DataType.Password)] [Required] public string Password { get; set; } [Compare("Password")] [DataType(DataType.Password)] [Required] public string ConfirmPassword { get; set; } } }
вот мой контроллер:-
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using EBpass.Models; using System.Collections; namespace EBpass.Controllers { public class AccountController : Controller { private void PopulateLookups(eBusPassSystemEntities db) { IEnumerable<SelectListItem> item = db.tbl_state.Select(C => new SelectListItem { Value = C.state_name, Text = C.state_name }).ToList(); ViewBag.state = item; IEnumerable<SelectListItem> itenn = db.tbl_city.Select(C => new SelectListItem { Value = C.city_name, Text = C.city_name }).ToList(); ViewBag.city = itenn; } [HttpGet] public ActionResult register(tbl_state t) { using (eBusPassSystemEntities db = new eBusPassSystemEntities()) { PopulateLookups(db); } return View(); } [HttpPost] public ActionResult Register(tbl_user u, HttpPostedFileBase image1) { if (!ModelState.IsValid) { using (eBusPassSystemEntities db = new eBusPassSystemEntities()) { PopulateLookups(db); } return View(); } using (eBusPassSystemEntities Db = new eBusPassSystemEntities()) if (image1 != null) { u.Profile = new byte[image1.ContentLength]; image1.InputStream.Read(u.Profile, 0, image1.ContentLength); Db.tbl_user.Add(u); Db.SaveChanges(); } TempData["message"] = "Hello" + u.UserName + " Your Account Has been Succesfully created."; return RedirectToAction("Success"); } [HttpGet] public ActionResult Success() { ViewBag.message = TempData["Thank you for Registration Now go to login"]; return View(); } //login public ActionResult Login() { return View(); } [HttpPost] [ValidateAntiForgeryToken] public ActionResult Login(tbl_user user) { using (eBusPassSystemEntities Db = new eBusPassSystemEntities()) { var usr = Db.tbl_user.Single(u => u.UserName == user.UserName && u.Password == user.Password); if (usr != null) { Session["User_id"] = usr.User_id.ToString(); Session["UserName"] = usr.UserName.ToString(); Session["Password"] = usr.Password.ToString(); return RedirectToAction("Loggedin"); } else { ModelState.AddModelError("", "username or password is incorrect."); } } return View(); } public ActionResult Loggedin() { if (Session["User_id"] != null) { return View(); } else { return RedirectToAction("login"); } } public ActionResult edit() { return View(); } public ActionResult Edit(int id, tbl_user collection) { if (Request.QueryString["User_id"] != null) { eBusPassSystemEntities db = new eBusPassSystemEntities(); var q = from abc in db.tbl_user where abc.User_id == id select abc; IList lst = q.ToList(); tbl_user userLook = (tbl_user)lst[0]; userLook.UserName = collection.UserName; userLook.Password = collection.Password; db.SaveChanges(); return RedirectToAction("Index"); } else { return View("login"); } } } }
Что я уже пробовал:
я перепробовал много способов
в основном я хочу получить и отредактировать информацию о текущих пользователях loggedin