You should not need the query string parameters since they exist in the BidViewModel
you post. The point of a POST request is that you don't have query string parameters.
I think you have to use this overload of the Html.BeginForm
method:
@using (Html.BeginForm("SubmitBid", "Tender", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
@Html.HiddenFor(model => model.Id)
@Html.HiddenFor(model => model.BidId)
// Other properties..
<button type="submit">Save</button>
}
Now it will post to http:localhost/Tender/SubmitBid
with the properties of BidViewModel
as post values, which contain Id
and BidId
. The signature of the POST action can stay the same:
[HttpPost]
public ActionResult SubmitBid(BidViewModel model)
{
string id = model.Id;
string bidId = model.bidId;
// ...
}
It's also possible that AttributeRouting causes this issue. Can you try this with native ASP.NET MVC routing? You could use this specific route for submitting bids:
routes.MapRoute(
name: "SubmitBid",
url: "Tender/SubmitBid/{id}/{bidId}/",
defaults: new
{
controller = "Tender",
action = "SubmitBid",
id = UrlParameter.Optional,
bidId = UrlParameter.Optional
});