I am working on a website,i have a view in my website for registration, and on pressing the signup button i am hitting an ActionMethod,every thing is working fine the problem is when after successful registration if user presses Enter on URL it is showing The resource cannot be found, how can i handle this?
Below is my controller code ==>
public ActionResult Join(SignUpModel model)
{
int create = Repository1.Create(UserEntity);
if (create > 0)//if <= 0 means username already exists
{
int savesetup = Repository2.SaveInfo(model);
TempData["SucessMsg"] = "User registered Successfully";
return View("Index");
}
if (create < 0)
{
TempData["ErrorMessage"] = "Username already exists";
return View("Index", model);
}
return RedirectToAction("Index", "SignUp");
}
and the View of Signup is Index View
public ActionResult Index()
{
return View();
}
Since i dont have View named Join,instead i am redirecting it to index page but when User is on Signup/Join URL and presses enter it shows The resource cannot be found
Is
ActionResult Join(SignUpModel model)marked with a [HttpPost]-attribute? If so, then it will only be invoked if the user makes a POST-request (and entering the url themselves will do a GET-request. If this is the case, simply add another action method called Join() without the [HttpPost]-attribute and use that to redirect them to the correct page (or display any information you want of course).Edit
I was a little hasty when reading your question and missed that you already redirected the user away from
ActionResult Join(SignUpModel model), sorry for that.