i have two form in my sites but both are submitting on same action ,
i form open in fancy-box and one open in a normal page ,
you can i know that the request is made from fancy-box
or the noraml page , because if form submission fails due
to validation i have to send back the same view with validation
errors from which user made request .
public ActionResult SubtmitForm(contact model)
{
// here i will check whether request is from fancy-box form or from normal web page form
}
Note : i am using asp.net mvc3
There is nothing built in to say where a request originated, in particular not from how the browser requested it.
You need to build this into your model and populate the data in javascript (or otherwise).
Something like a
public bool FromFancyBox { get; set;};on the model with aHiddenForon the view.When opening the fancybox you set the value to
trueand when closing it, you set it to false (though there are other mechanisms).In the controller, test for this property.