Printing the report on the server side
(PrintToPrinter method)
Server side printing results in the report being generated on the Web Server and
being printed to a printer that is installed to the Web server.
Printing to a printer installed to the Web server requires that the process under
which ASP.NET is running have sufficient permissions to access Network
printers. In order to provide these permissions, changes to the account that the
ASPNET worker process runs under are necessary as well as changes to the
registry on the Web server.
By default, ASP.NET runs with the permissions of the local “machine”
(ASPNET account for the ASPNET worker process) account. In order to
achieve network printing through IIS (Internet Information Services), the
Framework should be run under the local SYSTEM account. To make this
change, it is necessary to edit the default configuration settings in the
Machine.config file. This file is located by default at:
C:\WINNT\Microsoft.NET\Framework\<VersionNumber>\CONFIG\
Where <VersionNumber> is the version of the .NET Framework installed to the
computer. The account setting is contained within the <ProcessModel> tag of
this file. The default setting for the account is:
userName="machine" password="AutoGenerate"
This can be changed to:
userName="SYSTEM" password="AutoGenerate"
Then save the file.
It is now possible to give the local SYSTEM account on the server permissions
to print. If the printer is a network printer, we must expose the network printer
to the local SYSTEM account. The reason behind this is that when a printer is
installed to a computer, the settings for this printer are stored in the registry
under the HKEY_CURRENT_USER registry hive (Registry file). The IIS
process will never use this registry hive since it always runs under the context of
the local SYSTEM account and cannot be logged onto a server as a “Current
User”. By default, the SYSTEM account does not have any printers set up in
the registry. There are two Microsoft knowledge base articles, Q152451 and
Q184291 that explain how to expose the printer settings to the System account.
Both of these articles require editing the registry on the Web server and copying
the printer settings from the HKEY_CURRENT_USER hive to the
HKEY_USERS/.DEFAULT hive