Close Menu
    DevStackTipsDevStackTips
    • Home
    • News & Updates
      1. Tech & Work
      2. View All

      Error’d: Pickup Sticklers

      September 27, 2025

      From Prompt To Partner: Designing Your Custom AI Assistant

      September 27, 2025

      Microsoft unveils reimagined Marketplace for cloud solutions, AI apps, and more

      September 27, 2025

      Design Dialects: Breaking the Rules, Not the System

      September 27, 2025

      Building personal apps with open source and AI

      September 12, 2025

      What Can We Actually Do With corner-shape?

      September 12, 2025

      Craft, Clarity, and Care: The Story and Work of Mengchu Yao

      September 12, 2025

      Cailabs secures €57M to accelerate growth and industrial scale-up

      September 12, 2025
    • Development
      1. Algorithms & Data Structures
      2. Artificial Intelligence
      3. Back-End Development
      4. Databases
      5. Front-End Development
      6. Libraries & Frameworks
      7. Machine Learning
      8. Security
      9. Software Engineering
      10. Tools & IDEs
      11. Web Design
      12. Web Development
      13. Web Security
      14. Programming Languages
        • PHP
        • JavaScript
      Featured

      Using phpinfo() to Debug Common and Not-so-Common PHP Errors and Warnings

      September 28, 2025
      Recent

      Using phpinfo() to Debug Common and Not-so-Common PHP Errors and Warnings

      September 28, 2025

      Mastering PHP File Uploads: A Guide to php.ini Settings and Code Examples

      September 28, 2025

      The first browser with JavaScript landed 30 years ago

      September 27, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured
      Recent
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»News & Updates»CodeSOD: The HTML Print Value

    CodeSOD: The HTML Print Value

    August 27, 2025

    Matt was handed a pile of VB .Net code, and told, “This is yours now. I’m sorry.”

    As often happens, previous company leadership said, “Why should I pay top dollar for experienced software engineers when I can hire three kids out of college for the same price?” The experiment ended poorly, and the result was a pile of bad VB code, which Matt now owned.

    Here’s a little taste:

    <span class="hljs-comment">// SET IN SESSION AND REDIRECT TO PRINT PAGE</span>
    Session[<span class="hljs-string">"PrintValue"</span>] = GenerateHTMLOfItem();
    Response.Redirect(<span class="hljs-string">"PrintItem.aspx"</span>, <span class="hljs-literal">true</span>);
    

    The function name here is accurate. GenerateHTMLOfItem takes an item ID, generates the HTML output we want to use to render the item, and stores it in a session variable. It then forces the browser to redirect to a different page, where that HTML can then be output.

    You may note, of course, that GenerateHTMLOfItem doesn’t actually take parameters. That’s because the item ID got stored in the session variable elsewhere.

    Of course, it’s the redirect that gets all the attention here. This is a client side redirect, so we generate all the HTML, shove it into a session object, and then send a message to the web browser: “Go look over here”. The browser sends a fresh HTTP request for the new page, at which point we render it for them.

    The Microsoft documentation also has this to add about the use of Response.Redirect(String, Boolean), as well:

    Calling Redirect(String) is equivalent to calling Redirect(String, Boolean) with the second parameter set to true.
    Redirect calls End which throws a ThreadAbortException exception upon completion. This exception has a detrimental effect on Web application performance. Therefore, we recommend that instead of this overload you use the HttpResponse.Redirect(String, Boolean) overload and pass false for the endResponse parameter, and then call the CompleteRequest method. For more information, see the End method.

    I love it when I see the developers do a bonus wrong.

    Matt had enough fires to put out that fixing this particular disaster wasn’t highest on his priority list. For the time being, he could only add this comment:

    <span class="hljs-comment">// SET IN SESSION AND REDIRECT TO PRINT PAGE</span>
    <span class="hljs-comment">// FOR THE LOVE OF GOD, WHY?!?</span>
    Session[<span class="hljs-string">"PrintValue"</span>] = GenerateHTMLOfItem();
    Response.Redirect(<span class="hljs-string">"PrintItem.aspx"</span>, <span class="hljs-literal">true</span>);
    

    [Advertisement]
    Keep all your packages and Docker containers in one place, scan for vulnerabilities, and control who can access different feeds. ProGet installs in minutes and has a powerful free version with a lot of great features that you can upgrade when ready.Learn more.

    Source: Read More 

    Facebook Twitter Reddit Email Copy Link
    Previous ArticlePassword Strength Estimator Validation in Laravel
    Next Article A Radio Button Shopping Cart Trick

    Related Posts

    News & Updates

    Building personal apps with open source and AI

    September 12, 2025
    News & Updates

    What Can We Actually Do With corner-shape?

    September 12, 2025
    Leave A Reply Cancel Reply

    For security, use of Google's reCAPTCHA service is required which is subject to the Google Privacy Policy and Terms of Use.

    Continue Reading

    Supercharging Workflows with AI Agent and Copilot Development🚀

    Web Development

    Agency Assassin

    Web Development

    The WAVLab Team is Releases of VERSA: A Comprehensive and Versatile Evaluation Toolkit for Assessing Speech, Audio, and Music Signals

    Machine Learning

    Vibe Coding: Game Changer or Catastrophe For App/Game Dev?

    Web Development

    Highlights

    SafePay ransomware: What you need to know

    June 27, 2025

    SafePay is a relatively new ransomware that is making a big impact. Find out how…

    Microsoft Outlook Vulnerability Let Attackers Execute Arbitrary Code Remotely

    June 11, 2025

    I’ve got my eye on this Kindle Essentials bundle deal during Amazon Prime Day (and its price dropped lower)

    July 10, 2025

    Google dicht actief misbruikt V8-beveiligingslek in Chrome

    June 3, 2025
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.