Redirect in asp.net 5

I am still involved with asp.net, and I am trying to redirect the Edit action in the controller from another controller, but I cannot find out how to make it work. this is what i have

return RedirectToAction("Edit", "Worker"); 

or

return RedirectToAction("Edit", "Worker", 25); 

I need it to be something like this: http: // localhost: xxxxx / Worker / Edit / 25

+1
source share
2 answers

You can do the following

return RedirectToAction("Edit", "Worker", new { id = 25}); 
+1
source

You can pass the route value parameters as an Route valueObject using the newKeyword ... as

return RedirectToAction("Edit", "Worker", new { id = 25}); 

, , ,

return RedirectToAction("Edit", "Worker", new { id = 25,name ="tushar"}); 

RouteValueDictionary,

RouteValueDictionary _routValueDict = new RouteValueDictionary();
_routValueDict.Add("param1", param1);
_routValueDict.Add("param2", param2); 

, :

return RedirectToAction("Edit", "Worker", _routValueDict );
+1

Source: https://habr.com/ru/post/1655769/


All Articles