Hello Brian,
Thanks very much for the quick response.
There is some difference when we spawn a process from asp.net web
application since it is spawn from a service. To verify it, we could simply
create a notepad process. From task manager, we could see that notepad.exe
is in process list. However, it is not shown in the desktop, because the
exe exists on another desktop.
Any printing operation depends on registry entries located in
HKEY_CURRENT_USER. This registry hive is dynamic. Depending on which user
context the process is running under, different information will be loaded
into this hive. ASP pages run under IIS, which is running as the SYSTEM
account. When we print something in the ASP code, by default, it will also
run as the SYSTEM account. By default, the SYSTEM account does not have any
printers set up in the registry.
There are several ways to resolve this issue:
A. set up printers for the SYSTEM account to resolve this problem. To set
up printers for the SYSTEM account, perform the following:
This method requires you to modify the registry using the Registry Editor.
WARNING: Using Registry Editor incorrectly can cause serious, system-wide
problems that may require you to reinstall Windows to correct them.
Microsoft cannot guarantee that any problems resulting from the use of
Registry Editor can be solved. Use this tool at your own risk.
1. Ensure that the user you are currently logged into on the server has the
desired printers installed.
2. Launch the Registry Editor (Regedit.exe).
3. Select the following key:
HKEY_CURRENT_USER
\Software\Microsoft\Windows NT\Current Version\Devices
4. From the Registry menu, click Export Registry File.
5. In the File Name text box, type c:\Devices.reg.
6. Select the following key:
HKEY_CURRENT_USER
\Software\Microsoft\Windows NT\Current Version\PrinterPorts
7. From the Registry menu, click Export Registry File.
8. In the File Name text box, type c:\PrinterPorts.reg.
9. Select the following key:
HKEY_CURRENT_USER
\Software\Microsoft\Windows NT\Current Version\Windows
10. From the Registry menu, click Export Registry File.
11. In the File Name text box, type c:\Windows.reg.
12. From the Start button, select Run. Open Devices.reg in Notepad by
typing Notepad Devices.reg in Run dialog box.
13. Replace the text HKEY_CURRENT_USER with HKEY_USERS\.DEFAULT
14. Save the file. Then import it into the registry by double-clicking the
file in Windows Explorer.
15. Repeat steps 13 through 15 for PrinterPorts.reg and Windows.reg.
B. Run the ASP code in the interactive user who currently logged onto the
web server.
1. Open IIS manager and set the Application Protection of this web project
to High, which causes IIS to create a COM+/MTS package in COM+/MTS.
2. Open MTS or COM+ manager and change the Identity of the package created
above to Interactive User.
Note: This only works when one user with sufficient permission and printer
information in its registry logged on to the web server.
Please post here if you have any more concerns on it.
Best regards,
Yanhong Huang
Microsoft Online Partner Support
Get Secure! -
www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
!From: (e-mail address removed) (Brian Hanson)
!Newsgroups: microsoft.public.dotnet.general
!Subject: Re: Printing a pdf in an asp.net app
!Date: 15 Sep 2003 12:47:08 -0700
!Organization:
http://groups.google.com/
!Lines: 54
!Message-ID: <
[email protected]>
!References: <
[email protected]>
<
[email protected]>
<
[email protected]>
<
[email protected]>
<
[email protected]>
<
[email protected]>
<
[email protected]>
<
[email protected]>
!NNTP-Posting-Host: 131.184.58.5
!Content-Type: text/plain; charset=ISO-8859-1
!Content-Transfer-Encoding: 8bit
!X-Trace: posting.google.com 1063655230 587 127.0.0.1 (15 Sep 2003 19:47:10
GMT)
!X-Complaints-To: (e-mail address removed)
!NNTP-Posting-Date: 15 Sep 2003 19:47:10 GMT
!Path:
cpmsftngxa07.phx.gbl!cpmsftngxa10.phx.gbl!TK2MSFTNGXA05.phx.gbl!TK2MSFTNGP08
..phx.gbl!news-out.cwix.com!newsfeed.cwix.com!prodigy.com!pd2nf1so.cg.shawcab
le.net!residential.shaw.ca!sn-xit-03!sn-xit-01!sn-xit-06!sn-xit-09!supernews
..com!postnews1.google.com!not-for-mail
!Xref: cpmsftngxa07.phx.gbl microsoft.public.dotnet.general:108286
!X-Tomcat-NG: microsoft.public.dotnet.general
!
!Hi Yanhong,
!
!Here's the latest.
!
!1) Do I really want to print on the server side? Yes.
!
!2) The printer is set up locally for aspnet and the rest of the
!village and impersonation is being used (6 threads ago)... and still
!no luck.
!
!I found a third party piece of software to do the job because
!something (else) is keeping me from doing the process.start thing.
!
!Thanks
!
!
!
!> Hello Brian,
!>
!> Thanks for posting in the group.
!>
!> After reviewing the whole post thread, I think we need to clarify some
!> points here:
!>
!> 1) Do you really want to print the pdf file in server side? In ASP.NET,
the
!> codes are running on server side. That is to say, if we use
Process.Start
!> to print the file, the file is printed in your web server side, not web
!> client side. Please make sure that it is what you need.
!>
!> 2) If we confirm that pdf is to be printed in server side, then we come
to
!> consider this:
!> The printer you configured at the server is for the interactive user.
That
!> means, if you log on the server using the account bdhanson and setup the
!> printer, the printer is only available for bdhansonand others cannot see
!> the printer. By default, your ASP.NET worker process is using the ASPNET
!> account so it cannot even see the printer.
!>
!> To let your asp.net app see the printer, you need use impersonation.
Please
!> check the following article and I hope it helps.
!> Q306158 INFO: Implementing Impersonation in an ASP.NET Application
!>
http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q306158
!>
!> You may also need to load the profile of the interactive user here to
make
!> it work.
!>
!> Generally speaking, we use "Crystal Report" to print doc from asp.net,
!> which should be easiler. You could search in google for many samples in
!> this area.
!>
!> Hope that helps.
!>
!> Best regards,
!> Yanhong Huang
!> Microsoft Online Partner Support
!