无法在iis应用程序中浏览网络打印机 [英] unable to browse network printers in iis app

查看:84
本文介绍了无法在iis应用程序中浏览网络打印机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个iis应用程序,我想浏览网络打印机.我冒充登录用户,但看不到任何网络打印机.如果我(已登录的用户)在桌面上使用设备和打印机",则可以看到几台打印机,但是没有显示 响应iis中的代码.

I have an iis app and I want to browse for network printers. I am impersonating as the logged on user but I don't see any network printers. If I (the logged on user) use Devices and Printers on the desktop, I can see several printers but none of them show up in response to the code in iis.

这是我的代码:

            List<string> printers = new List<string>();
            System.Security.Principal.WindowsIdentity identity = System.Security.Principal.WindowsIdentity.GetCurrent();
            using (identity.Impersonate())
            {
                System.Management.ObjectQuery oquery = new System.Management.ObjectQuery("SELECT * FROM Win32_Printer");
                System.Management.ManagementObjectSearcher mosearcher = new System.Management.ManagementObjectSearcher(oquery);
                System.Management.ManagementObjectCollection moc = mosearcher.Get();
                foreach (ManagementObject mo in moc)
                {
                    printers.Add(mo["Name"].ToString());
                }
            }

如果我使用设备和打印机",要将网络打印机添加到台式机上的可用打印机中,然后我会在iis代码中看到该打印机,但看不到其他任何可访问的网络打印机

If I use "Devices and Printers" to add a network printer to my available printers on the desktop, I will then see that printer in my iis code, but not any other network printers that are accessible

推荐答案

法纳姆,

您知道Web应用程序背后的代码在服务器上而不是在桌面上运行吗?因此,您看不到用户/台式机的任何打印机.

you are aware that the code behind an Webapplication is running on the server and not on the Desktop? So you cannot see any printers of the user / desktop.

如果要在桌面系统上运行代码,则需要ActiveX控件之类的解决方案(需要安装某些东西,依此类推.也许您知道某些页面会询问您是否要安装某些东西) .)但是到底是怎么做的 你想实现?通常,用户将使用浏览器来查看来自IIS的页面.浏览器负责呈现页面并将其显示给用户或发送给打印机.但是,选择打印机和所有这些东西是 浏览器,而不是webserver/iis/web应用程序.

If you want to have code running on the desktop system, you need a solution like ActiveX controls (that is something that needs to be installed and so on. Maybe you know some pages where you get asked if you want to install something.) but what exactly do you want to achieve? Normaly users will use a browser to view the pages that come from IIS. The browser is responsible to render the page and either display it to the user or send it to a printer. But choosing a printer and all that stuff is the job of the browser and not of the webserver/iis/web application.

请澄清我是否误解了你.

Please clarify if I missunderstood you.

以诚挚的问候,

Konrad


这篇关于无法在iis应用程序中浏览网络打印机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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