jason
jason

Reputation: 7164

Redirect to another controller with an argument in ASP.NET

I have this controller :

public ActionResult Giris(string KimlikNo)
{
    return RedirectToAction("YeniBelge");
}

I have another controller :

public ActionResult YeniBelge(string KimlikNo)
{
    //do stuff
}

How can I pass KimlikNo's value to YeniBelge controller? Thanks.

Upvotes: 0

Views: 1622

Answers (1)

user3559349
user3559349

Reputation:

You can pass it using a route value. I assume you mean another method, not another controller

return RedirectToAction("YeniBelge", new { KimlikNo = KimlikNo });

If the methods are in different controllers, then use

return RedirectToAction("YeniBelge", "OtherControllerName", new { KimlikNo = KimlikNo });

Upvotes: 2

Related Questions