How to add query string from surface controller in mvc umbraco to save model values

How to add query string from surface controller in mvc umbraco. This is my current code.

I originally wrote code like

public ActionResult Registration(RegisterModel model)
{ 
  //Code to insert register details
  ViewBag.Success="Registered Successfully"
  return CurrentUmbracoPage();
}

with this, I could successfully save the ViewBag value and model properties, but I could not add a query string with it.

With a specific requirement, I have to change the code returning the url with querystring. which i did as below

public ActionResult Registration(RegisterModel model)
{ 
    //Code to insert register details
    ViewBag.Success="Registered Successfully"
    pageToRedirect = AppendQueryString("success");
    return new RedirectResult(pageToRedirect);
}
public string AppendQueryString(string queryparam)
{
    var pageToRedirect = new DynamicNode(Node.getCurrentNodeId()).Url;
    pageToRedirect += "?reg=" + queryparam;
    return pageToRedirect;
}

and with this, my property values ​​in the model could not be saved, and the ViewBag returned with a zero value.

Can anyone suggest me how to add a query string while storing the values ​​in the model and ViewBag.

+4
source share
1 answer

ViewBag . , TempData, , TempData.Add("CustomMessage", "message");

+1

All Articles