I have an mvc form (made from a model) which when submitted, I want to get a parameter I have the code to set the form and get the parameter
using (@Html.BeginForm("myMethod", "Home", FormMethod.Get, new { id = @item.JobId })){
}
and inside my home controller I have
[HttpPost]
public FileStreamResult myMethod(string id)
{
sting str = id;
}
However, I always get the error
The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
When I omit the [HttpPost]
, the code executes file but the variables str
and id
are null.
How can I fix this please?
EDIT
Can this be caused because myMethod in the controller is not an ActionResult? I realized that when I have a method of type Actionresult where the method is bound to a view, everything works well. But the type FileStreamresult cannot be bound to a View. How can I pass data to such methods?