Rawprinterhelper 网络打印机 ASP.NET MVC
我在尝试使用 RawPrinterHelper(Microsoft 开发的打印机支持类)从 ASP.NET MVC3 应用程序打印文档时遇到问题。我需要将 RAW 数据发送到本地连接到网络计算机的打印机。
在我的开发环境(MS Visual Studio 2010)中,一切运行良好。我在操作系统中将打印机安装为网络打印机,并将该打印机的名称传递给 RawPrinterHelper。 在真正的测试服务器上,事情根本不起作用。操作系统是带有 IIS7 的 Windows 7。 事实上,我需要通过在 IIS 上运行的应用程序使用安装在本地 Windows7 客户端上的网络打印机。 应用程序池标识设置为“网络服务”。 使用 Visual Studio 2010 的内置 Web 服务器一切正常。 所有打印机都经过测试并且可以工作。 谢谢。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我解决了这个问题。问题是 ASP.NET 应用程序在 IIS 服务器上运行,并且无法访问网络打印机,而只能访问本地打印机。然后,Windows 操作系统中的每个用户只能访问他自己的网络打印机。
该问题可以通过以下方式解决:
1)用操作系统的用户模拟 ASP.NET 应用程序
2)授予用户使用数据库等的权限
3) 创建并使用特定的用户配置文件登录您的网络打印机
4) 就绪
为RawPrinterHelper 提供正确的字符串格式名称非常重要。为此,请检查 System.Drawing.Printing.PrinterSettings 并获取已安装打印机的列表。
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.