9

I am creating a website for User registeration,display,login etc. I am currently trying to display the details of the user who have signed in. But within the actionResult of login I don't know how will i call the actionResult of display? I am new to asp.net. I need suggestions

public ActionResult login()
{
    try
    {
        return View();
    }
    catch (Exception ex)
    {
        throw ex;
    }
}

[HttpPost]     
public ActionResult login(DEntities.Users user)
{
    try
    {
        services.CheckUser(user);
        controlsuccess = services.servicesuccess;
        if (controlsuccess == true)
        {

            return RedirectToAction("display");             
            //return View("display");
        }
        else
        { 
            return HttpNotFound();
        }
    }
    catch (Exception ex)
    {
        throw ex;
    }
}

public ActionResult display()
{
    return View();
}

[HttpPost]
public ActionResult display(int id = 0)
{
    try
    {
        DEntities.Users user = services.GetUserbyId(id);
        return View(user);

    }
    catch (Exception ex)
    {
        throw ex;
    }
}
Satpal
  • 132,252
  • 13
  • 159
  • 168
Shanida
  • 91
  • 1
  • 1
  • 4
  • Tag your questions correctly so that it comes in focus of appropriate users and spend some time to format your question – Satpal Nov 07 '13 at 07:28

1 Answers1

21

Remove the [HttpPost] attribute from the display action.

If both actions are in the same controller, then just pass the action name:

return RedirectToAction("display", new { id = 1 });

Or if the actions are in different controllers, pass the action and controller names:

return RedirectToAction("display", "controllername", new { id = 1 });

Or if it is necessary to use [HttpPost], you can learn how to RedirectToAction to a POST Action.

CarenRose
  • 1,266
  • 1
  • 12
  • 24
Nirmal
  • 924
  • 4
  • 9