ASP.NET IIS 服务器端打印失败 [英] ASP.NET IIS server side printing fails

查看:26
本文介绍了ASP.NET IIS 服务器端打印失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个需要使用 PrintDocument 方法打印的 ASP.NET 应用程序:

I'm building an ASP.NET application that requires printing using PrintDocument method:

PrintDocument.Print()

在带有 IIS express 的开发环境中打印工作正常.发布到内网IIS服务器,打印失败,我认为是aspnet工作进程权限问题.

Printing works properly in development env with IIS express. when publishing it to an intranet IIS server, printing fails, which I think is caused by permission issue for aspnet working process.

我尝试执行以下操作但没有成功:

I tried to do the following with no success:

  • 我在集成管道模式下为管理员本地用户创建了一个应用程序池,加载用户配置文件 选项设置为 true
  • 我将应用程序移至新创建的应用程序池
  • 我在 web.config 文件中添加了 <identity impersonate="true" username="username" password="*****"/>
  • 出现错误,指出:检测到不适用于集成托管管道模式的 ASP.NET 设置,因此我添加了 <validation validateIntegratedModeConfiguration="false"/> 部分.
  • I created an application pool in integrated pipeline mode for an admin local user with load user profile option set to true
  • I moved the application to the new created application pool
  • I added <identity impersonate="true" username="username" password="*****"/> in web.config file
  • An error appeared stating that: An ASP.NET setting has been detected that does not apply in Integrated managed pipeline mode so I added <validation validateIntegratedModeConfiguration="false"/> to <system.webServer> section.

有什么帮助吗?

推荐答案

我想你可能误解了这里的一些基本概念.当您使用 PrintDocument.Print() 时,您正在服务器上打印.当您在 IIS 中部署您的应用程序时,此打印将在托管您的应用程序的服务器计算机上进行.您认为您的代码在 IIS Express 中工作的原因是因为您将应用程序托管在与测试它的客户端浏览器相同的计算机上.此外,您正在使用配置了打印机的帐户运行应用程序.

I think you might be misunderstanding some fundamental concepts here. When you use PrintDocument.Print() you are printing on the server. When you deploy your application in IIS this printing will happen on the server computer that is hosting your application. The reason why you thought your code was working in IIS Express is because you were hosting your application on the same computer as the client browser that was testing it. Also you were running your application under your account which had a printer configured.

您无法从 Web 应用程序直接打印到客户端计算机.那将是一个很大的安全问题.您能做的最好的事情是提供一些使用打印的 HTML 文档 media CSS type.然后,如果用户决定,他可能会在浏览器中打印出来.

You cannot print directly to the client computer from a web application. That would be a big security issue. The best you could do is provide some HTML document using a print media CSS type. Then if the user decides, he might print it in his browser.

另一方面,如果您想在连接到 Web 服务器的某些打印机上打印,则需要在 IIS 中配置应用程序池,以在其配置文件中配置了打印机的身份下运行.

If on the other hand you want to print on some printer that is attached to your web server, you will need to configure the Application Pool in IIS to run under an identity that has a printer configured in its profile.

这篇关于ASP.NET IIS 服务器端打印失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆