Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7446357
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T12:17:32+00:00 2026-05-29T12:17:32+00:00

I have a tag object that is loaded dinamically by javascript. This tag is

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T12:17:32+00:00Added an answer on May 29, 2026 at 12:17 pm

    Your code seems weird. You are sending a POST AJAX request to some controller action but you don’t seem to be doing anything in the success callback with the result (dados variable). Also you seem to be calling the VisualizarCredencial action twice: once for the AJAX request and once for rendering the PDF.

    You haven’t explained your intentions so I can only be guessing what you are trying to do, and my guess is that you could have 2 controller actions: once that returns the url or an id that could be used to query the second controller action that will return the pdf.

    Like this:

    [HttpPost]
    public ActionResult VisualizarCredencial()
    {
        // some id of the pdf
        return Json(new { url = Url.Action("GetPdf", "GerenciarCredenciais", new { id = "123" }) });
    }
    
    public ActionResult GetPdf(int id)
    {
        byte[] pdf = ... 
        return File(pdf, "application/pdf");
    }
    

    and now on the client you could use an iframe:

    var url = '@Url.Action("VisualizarCredencial", "GerenciarCredenciais")';
    $.post(url, function(result) {
        $('#preview_credencial').html(
            $('<iframe/>', {
                'class': 'pdfpreview', // some CSS class to set the width and height of the preview iframe
                'src': result.url
            })
        );
    });
    

    and to avoid potential caching problems with the GepPdf action you could decorate it with a custom [NoCache] action filter.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a .tag file that requires a JavaScript library (as in a .js
I have an object I created in JavaScript. Let's say it looks like this:
I have two List's that contain a object of Tag like List i need
I have an aspx page that includes a javascript file in the head tag.
I have a span tag as parent to an object tag that loads a
I have this very simple script that allows the user to specify the url
I have to add either an embed tag for Firefox or an object tag
I have the following method which serialises an object to a HTML tag. I
I have two models, Image and Tag . Each Image object can have more
i have this tag as input tag: <a href=controller.jsp?sid=127490C88DB5&R=35144 class=11-link-dkred-bold><b>Mr. John Q. Anderson&nbsp;&nbsp;&nbsp;MBA 1977

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.