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

  • SEARCH
  • Home
  • 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 3783336
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T11:12:36+00:00 2026-05-19T11:12:36+00:00

I am trying to print a web page at the default printer on the

  • 0

I am trying to print a web page at the default printer on the web server. I found the holy grail and it works but prints the login page not the target page, which makes sense because the controller requires auth using the asp.net membership with stock setup. I found this writeup where it is mentioned that you can use the dom interfaces if using forms auth (think that’s me) but I’m not sure how to do that. It sounds like that would let the browser hit the login page and post the username/password back to finally hit the target page? Any insight on the best way to proceed would be very helpful, I would not have imagined it would be this involved to print a page that is already rendered (although printing server side it does kinda make sense). Thanks!

Edit: This works: (apparently cookie is the one thing you cannot set in the browser.Navigate method call)

            HttpCookie cookie = Request.Cookies[".ASPXAUTH"];

            InternetSetCookie(htmlPath, ".ASPXAUTH", cookie.Value);

            browser.Navigate(htmlPath);
            while (browser.ReadyState != WebBrowserReadyState.Complete)
                Application.DoEvents();

            dynamic ie = browser.ActiveXInstance;
            ie.ExecWB(OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER, PRINT_WAITFORCOMPLETION);

and separately:

            [DllImport("wininet.dll", CharSet = CharSet.Auto, SetLastError = true)]
            static extern bool InternetSetCookie(string lpszUrl, string lpszCookieName, string lpszCookieData);

This could be further improved using your code to get the forms cookie specifically instead of by name as my code.

  • 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-19T11:12:37+00:00Added an answer on May 19, 2026 at 11:12 am

    The WebBrowser control has an overload method of the Navigate method which allows you to pass additional HTTP headers to the request. In the last argument you could pass the cookie header like this:

    browser.Navigate(htmlPath, null, null, "Cookie: authCookie=value" + Environment.NewLine);
    

    where obviously you need to replace authCookie with the name of the authentication cookie your web site expects and value with the value taken from the request cookie.

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

Sidebar

Related Questions

I am trying to print a message on a web page in vb.net. I
Using the InternetExplorer object, I'm able to print a web page. But when I
I'm trying to print/save a certain element's HTML from a web-page. I've retrieved the
I'm trying to put a print button on a web page that will print
I'm just trying to open a web page with pyphantomjs , but it makes
I am trying to submit a login form on a web page that looks
I'm trying to print a string from an archived web crawl , but when
Im trying print Excel file data on a page. To do it i used
I'm trying to print out a list of products on a page. This is
I am trying to create an application to print documents over the web. I

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.