none
Printing from ASP.NET to a network printer

    Question

  • I need to send documents to a network printer (\myserver\myprinter). I'm using the System.Printing classes to print, and it works fine when it's from a Windows Service, but from an ASP.NET app, it's only able to print to local printers, not network printers. The error I'm getting is "Printer Name is not valid" This is what I'm using to get the printer name:

    public string PrinterName
    {
       
    using (LocalPrintServer server = new LocalPrintServer())
       
    return server.GetPrintQueue(@"\\myserver\myprinter");
    }

    It works fine if I print to \myserver\myprinter from Notepad directly, just not from code.  I'm on .NET 4.0/VS2010 and using ASP.NET Development Server.
    • Moved by eryang Monday, September 20, 2010 12:54 AM (From:.NET Base Class Library)
    Thursday, September 16, 2010 7:26 PM

All replies