I have a tag object that is loaded dinamically by javascript. This tag is loaded after a jquery post:
$.post('@Url.Action("ShowCredential", "ManageCredentials")',
$(form).serialize(), function(url) {
document.getElementById("credential_preview").innerHTML = "<object id='credencial_atual' type='application/pdf' classid='clsid:CA8A9780-280D-11CF-A24D-444553540000' width='250' height='420' style='border: 1px solid'> <param name='src' value='" + url + "#navpanes=0&scrollbar=0&zoom=100%' /></object>";
$("#preview_popup").show();
});
Obs: i load the form variable with my form.
In my code-behind of the action "ShowCredential" i load a pdf in byte[] and store in my user session:
[HttpPost]
public string ShowCredential(/* the attributes to help to load the pdf */)
{
// Loading my pdf...
Session.User.CurrentPDF = // set the pdf loaded
UrlHelper urlHelper = new UrlHelper(this.ControllerContext.RequestContext);
string url = urlHelper.Action("GetPDF", "ManageCredentials");
return url;
}
The url is generated with the action that will return the pdf.
[HttpGet]
public FileResult GetPDF()
{
return File(Session.User.CurrentPDF, "application/pdf");
}
So, in the first time, ok, is loaded the right pdf, but in the second, third... is loaded the same pdf, why? (i checked if i pass the right params, yes i pass =))
Obs: When i post the data to load the pdf, after - in jquery return - my code call the action GetPDF in the first time, but, when i post again, the action GetPDF is not called anymore.