开发者

Using DocumentPrint in ASP.NET

开发者 https://www.devze.com 2023-03-26 17:19 出处:网络
I made a small web application (ASP.NET) that use the DocumentPrint.Print() to use a printer that connected on the server and when run it from the visual studio its work well and print the document co

I made a small web application (ASP.NET) that use the DocumentPrint.Print() to use a printer that connected on the server and when run it from the visual studio its work well and print the document correctly, Hint : the address will be : http://localhost:8080/ but when use the iis server (http://localhost/TestPrintingWebSite) the printer never work and then the website didnt effect to the server printer.

is there any setting must be on the iis to开发者_Go百科 let me able to use the server printer ???

please your help guys ;)

thanks alot


By default in IIS, the account used to run ASP.NET applications will lack sufficient privelages to access the network printer.

In order to access the printer you will need to either use impersonation in your code:

WindowsIdentity.Impersonate Method

Or configure IIS to run the application under a user account with the required privileges.

Here is another article which explains different methods of impersonation security:

Understanding ASP.NET Impersonation Security


Edit

If you do not feel confident implementing the user impersonation code yourself, here is a link to a codeproject article: (the code is in c# but could be easily converted to VB.NET or compiled into a separate class library and used in your application)

A small C# Class for impersonating a User

0

精彩评论

暂无评论...
验证码 换一张
取 消