I am passing a query string to my account controller from a external source and I would like to add these values to the model and return the view. The below code is working but it is returning the view with the all the validation errors for the missing fields. I would simply like it to return the view with these fields populated?
One other issue is that I would like to return a clean url like /Account/Register without the Query String on the end of the address?
// **************************************
// URL: /Account/WriteRegistration/?Number=251911083837045755&Name=All&Remote=False
// **************************************
public ActionResult WriteRegistration(RegisterModel model, string Number, string Name, bool Remote)
{
model.Number = Number;
return View("Register", model);
}
I think you may be approaching this badly.
If you’re using a query string to populate your view, do this instead:
If you’re looking for a clean URL, you may want to consider using a POST instead… that is, creating a form and submitting via a submit button. In that case you would do this:
I think your original code was mixing both approaches.