none
"Timeout error" is thrown on printing the document using IIS and the network printer RRS feed

  • Question

  • Hi Team,

    My scenario is to print the document using IIS and the network printer in ASP.NET MVC platform.

    The Printing is working fine for the below code snippet with IIS Express, but when we host the sample in IIS (in production environment) , we are getting “Timeout error” on printing.

    Please find the code snippet:

    private void print_Click(object sender, EventArgs e)

            {

                PrintDocument printDocument = new PrintDocument();

                printDocument.PrintPage += new PrintPageEventHandler(Printing);

                printDocument.Print();      

            }

            void Printing(object o, PrintPageEventArgs e)

            {

                string path=Server.MapPath("~/Data/image.bmp");

                System.Drawing.Image i = System.Drawing.Image.FromFile(path);

                Point p = new Point(100, 100);

                e.Graphics.DrawImage(i, p);

            }

    Please help me to resolve this issue.

    Thanks in Advance,

    Akshaya

    Tuesday, May 16, 2017 5:39 AM

All replies

  • Hello Akshaya,

    Is  there additional detail in an inner exception?  Anything logged in eventviewer that might relate?

    My guess is this is security with the IIS application pool identity.  My suggestion is to set the app pool to have run as a AD user that has access to the network printer. 


    Cheers, Jeff

    Tuesday, May 16, 2017 10:12 PM
  • Hi ,

    Thank you for your reply.

    We are running the app in Administrator mode only, but still we are getting the exception .Please find the exception details below,

    The operation has timed out

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.  Exception Details: System.Net.WebException: The operation has timed out

    Stack Trace: 

    [WebException: The operation has timed out]

       System.Net.HttpWebRequest.GetResponse() +1743

       System.ServiceModel.Channels.HttpChannelRequest.WaitForReply(TimeSpan timeout) +75

    [TimeoutException: The HTTP request has exceeded the allotted timeout of 00:00:59.9530000. The time allotted to this operation may have been a portion of a longer timeout.]

       System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException webException, HttpWebRequest request, HttpAbortReason abortReason) +7225613

       System.ServiceModel.Channels.HttpChannelRequest.WaitForReply(TimeSpan timeout) +825

       System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout) +255

    [TimeoutException: The request channel timed out while waiting for a reply after 00:00:59.9469635. Increase the timeout value passed to the call to Request or increase the SendTimeout value on the Binding. The time allotted to this operation may have been a portion of a longer timeout.]

       System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) +14493634

       System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) +388

       lambda_method(Closure , ControllerBase , Object[] ) +139

       System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +229

       System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +35

       System.Web.Mvc.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState) +39

       System.Web.Mvc.Async.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult) +71

       System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +42

       System.Web.Mvc.Async.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3d() +72

       System.Web.Mvc.Async.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() +386

       System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) +42

       System.Web.Mvc.Async.<>c__DisplayClass2b.<BeginInvokeAction>b__1c() +38

       System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult) +186

       System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +38

       System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +29

       System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +67

       System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +53

       System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +36

       System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +38

       System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +44

       System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +67

       System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +38

       System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +399

       System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +157

    Kindly suggest me a solution on this.

    Thanks,

    Akshaya

    Tuesday, May 23, 2017 10:49 AM
  • Hello Akshaya,

    I am not sure what you mean by Administrator mode.  On the production server, what is the App pool identity that the application pool is running under?  

    My hunch is the identity does not have access to the printer.  Here is a post that may help: https://msdn.microsoft.com/en-us/library/aa290045(v=vs.71).aspx

    Here is another post where they are printing to a specific printer name (my understanding is your code will require a default printer specified for the identity of the app pool):

    https://support.west-wind.com/Thread2R50HT61G.wwt


    Cheers, Jeff

    Tuesday, May 23, 2017 9:15 PM