Rawprinterhelper network printer ASP.NET MVC

江枫思渺然 提交于 2021-02-10 15:21:20

问题


I'm having trouble trying to print a document from a ASP.NET MVC3 application using RawPrinterHelper (the printer support class developed by Microsoft). I need to send RAW data to a printer which is locally connected to a computer in the network.

In my development environment (MS Visual Studio 2010) everything works well. I installed the printer in my OS as a network printer and I pass the name of that printer to RawPrinterHelper. On the real test server things don't work at all. The OS is Windows 7 with IIS7. Indeed I need to use a network printer installed on the local Windows7 client from my application running on IIS. The applicationpooling identity is set as "Network Service". Everything works using the built-in web server for Visual Studio 2010. All the printers are tested and work. Thanks.


回答1:


I solved the problem. The issue is that the ASP.NET application is running on the IIS server and does not have access to network printers, but only to local printers. Then, every user in Windows OS has access only to his own network printers. The problem can be solved in this way:

1) Impersonate the ASP.NET application with a user of the OS 2) Grant the user privileges to use databases, etc 3) Create, logged in with THAT specific user profile, your network printers 4) Ready

It is very important to provide RawPrinterHelper with the right name in string format. To do so check System.Drawing.Printing.PrinterSettings and get the list of installed printers.



来源:https://stackoverflow.com/questions/7502350/rawprinterhelper-network-printer-asp-net-mvc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!