locked
Web application server printing RRS feed

  • Question

  • User-296704440 posted

    Summary: I have developed a web application using VS Express 2013 for web, which uses ADO to connect to SQL Server to poll a table representing a print queue.  In the VS development environment, the application works fine, but when deployed under IIS as a LOCALHOSTed application, it runs ok, but I see no output (i.e print).  I am sending all printed output to the One Note 2013 printer driver.  When running in VS, you get to see the 'Printing page 1 of ' dialogue with the cancel button, but this is not seen from the locally deployed application.

    Further information: I very much suspect this is to do with users / permissions.

    The deployment of my application required the following steps:

    1. From IIS, ISAPI and CGI Restrictions - Make sure ASP.Net is 'Allowed'.

    2. Make sure my app runs my custom pool which runs a classic .net v4 framework - with my user name.  Without this I got into issues with the ADO connection.  I think I can drop this for production deployment on a dedicated web server.

    3. Edited my config to add items in red bold against relevant pool name:

    <add name="MyCustomPoolName" autoStart="true" managedRuntimeVersion="v4.0" managedPipelineMode="Classic">

                    <processModel identityType="SpecificUser" loadUserProfile="true" setProfileEnvironment="true" userName="mc\auser" 

    Also tried web config amendment (edited and then full machine restart) for app to include:

    <configuration>
        <system.web>
    <identity impersonate="true" userName="mc\auser" password="auser_password" />

    I am told that the web server is running as user ASP, but I thought it would run as my user since I specified it in the application pool settings?

    Also: I tried writing this program as a Windows Service and I seem to have similar issues there.  Even again when the service is run as the same user who can see the printer perfectly well in the VS environment.  I gave up on this due to several articles where it is stated MS do not support System.Drawing.Printing from a Service type application.

    I have read about various options for web application printing.  This is not about printing a representation of what the user is seeing in their browser.  The application requires a formatted printed output directed to a network / local printer.

    I would be interested in comments on the architecture used here and any suggestions on improvement.

    Also any comments about whether this issue would go away if I deployed my app on a true web server (not local hosted).

    Finally, any ideas on getting the prints to work as this would be an idea demonstration system.

    My environment is Win 7 sp1, IIS 7.5

    Thursday, December 17, 2015 6:41 PM

Answers

  • User-718146471 posted

    "Local-only type of deal" - does that mean client rather than server driven?  I see how a lot of web apps seem to handle printing.  They generate a new version of the client form (new client window), perhaps without the adverts, and then offer to print that form.  I presume that is easy since there are routines to just send a client form to a printer?

    Actually, I suspect they are using some type of ActiveX controls, Silverlight, or possibly Adobe Flash

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, December 23, 2015 1:09 PM

All replies

  • User-718146471 posted

    I am not going to hold out much hope for this because that functionality is much like Desktop. But what you could do is create a service account that has Admin privileges on the server side, make sure this admin belongs also to the IUSR groups. Once you get that to work, then scale back the permissions one right at a time until it breaks, then re-enable the right. You may need to also do advanced privileges like Logon as a service, Logon as a batch job, etc. I have run into problems like this before, trying to have the web application do voice synthesis. I wound up creating a windows service program to do the heavy lifting for that function.

    Thursday, December 17, 2015 7:23 PM
  • User-296704440 posted

    Many thanks for your reply.

    Can you expand on why my functionality is "like desktop" please?  Is there a preferred web approach?

    On Windows Service program I found the following at: http://stackoverflow.com/questions/7990/printing-from-a-net-service/8094#8094

    Printing from a service is a bad idea. Network printers are connected "per-user". You can mark the service to be run as a particular user, but I'd consider that a bad security practice. You might be able to connect to a local printer, but I'd still hesitate before going this route.

    The best option is to have the service store the data and have a user-launched application do the printing by asking the service for the data. Or a common location that the data is stored, like a database.

    I really do not understand the "preferred approach" to formatted printing for a web programme that is not based on a reproduction of the client UI?

    Thursday, December 17, 2015 11:33 PM
  • User-296704440 posted

    I should have mentioned my the user I am using has administrator privileges for both the pool and the impersonation. 

    Friday, December 18, 2015 11:14 AM
  • User-718146471 posted

    What you are running into is basic web server behavior. Printing is generally a local-only type of deal. Have you considered outputting the printout to PDFSharp? That will let you generate PDF files that can be dropped to a server folder. I do not think we can print to the OneNote on the server. Let me know if you would like to venture down this road.

    Friday, December 18, 2015 11:34 AM
  • User-296704440 posted

    "Local-only type of deal" - does that mean client rather than server driven?  I see how a lot of web apps seem to handle printing.  They generate a new version of the client form (new client window), perhaps without the adverts, and then offer to print that form.  I presume that is easy since there are routines to just send a client form to a printer?

    I'd be happy to look at any solution to this issue, including PDFSharp.  Presume I would need to start from scratch again without any reuse of my System.Drawing.Printing code?  What is it that PDFSharp does that makes it a solution for my printing scenario?

    Or...  Would I be best off just writing this as a Forms Application.  I am sure that would work.  I am pretty stunned that there is no solution to this in the web world Frown

    Friday, December 18, 2015 4:01 PM
  • User-718146471 posted

    "Local-only type of deal" - does that mean client rather than server driven?  I see how a lot of web apps seem to handle printing.  They generate a new version of the client form (new client window), perhaps without the adverts, and then offer to print that form.  I presume that is easy since there are routines to just send a client form to a printer?

    Actually, I suspect they are using some type of ActiveX controls, Silverlight, or possibly Adobe Flash

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, December 23, 2015 1:09 PM