ASP.Net MVC Redirect To A Different View | mvc redirect
Iamnot100%surewhattheconditionsareforthis,butformetheabovedidntworkdirectly,thoughtitgotclose.IthinkitwasbecauseIneeded"id"formyviewbyinthemodelitwascalled"ObjectID".Ihadamodelwithavarietyofpiecesofinformation.Ijustneededtheid.BeforetheaboveIcreatedanewSystem.Web.Routing.RouteValueDictionaryobjectandaddedtheneededid.(System.Web.Routing.)RouteValueDictionaryRouteInfo=newRouteValueDictionary();RouteInfo.Add("id",ObjectID);returnRedirectToAction("details",RouteInfo);(Note:theMVCprojectinquestio...
I am not 100% sure what the conditions are for this, but for me the above didnt work directly, thought it got close. I think it was because I needed "id" for my view by in the model it was called "ObjectID".
I had a model with a variety of pieces of information. I just needed the id.
Before the above I created a new System.Web.Routing.RouteValueDictionary object and added the needed id.
(System.Web.Routing.)RouteValueDictionary RouteInfo = new RouteValueDictionary(); RouteInfo.Add("id", ObjectID); return RedirectToAction("details", RouteInfo);(Note: the MVC project in question I didnt create, so I dont know where all the right "fiddly" bits are.)