Hi AliYilmaz,
Use TempData to send the value.
Check this example. Now please take its reference and correct your code.
Controller
HomeController
public class HomeController : Controller
{
// GET: /Home/
public ActionResult Index()
{
TempData["orderid"] = 30789213;
return View();
}
}
AddressController
public class AddressController : Controller
{
// GET: /Address/
public ActionResult Index()
{
// Get from TempData.
var orderIdTempData = TempData["orderid"];
if (orderIdTempData != null)
{
TempData["ReceivedId"] = orderIdTempData;
}
return View();
}
}
View
HomeController > Index
<button onclick="location.href='@Url.Action( "Index", "Address")';return false;">Send TempData</button>
AddressController > Index
<div>
<a href="@Url.Action("Index","Home")">Go Back</a>
@if (TempData["ReceivedId"] != null){
<script type="text/javascript">
window.onload = function () {
alert("@TempData["ReceivedId"]");
};
</script>
}
</div>
Screenshot