Ошибка сервера в приложении «/ DataService» - PullRequest
0 голосов
/ 26 октября 2018
  1. когда я пытаюсь вызвать API, иногда я получаю HTML с ответом
  2. вот HTML, который я получаю с ответом

    <code>   <html>
        <head>
            <title>Session state has created a session id, but cannot save it because the response was already flushed by the application.</title>
            <meta name="viewport" content="width=device-width" />
        </head>
    
        <body bgcolor="white">
            <span><H1>Server Error in '/DataService' Application.<hr width=100% size=1 color=silver></H1>
                <h2> 
                    <i>Session state has created a session id, but cannot save it because the response was already flushed by the application.</i> 
                </h2>
            </span>
    
            <font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif ">
                <b> Description: </b>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.
    
                <br><br>
    
                <b> Exception Details: </b>System.Web.HttpException: Session state has created a session id, but cannot save it because the response was already flushed by the application.<br><br>
    
                <b>Source Error:</b> <br><br>
    
                <table width=100% bgcolor="#ffffcc">
                <tr>
                    <td>
                        <code>
                            An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
                        </code>
                    </td>
                </tr>
                </table>
    
                <br>
    
                <b>Stack Trace:</b> <br><br>
    
                <table width=100% bgcolor="#ffffcc">
                <tr>
                    <td>
                        <code>
                            <pre>
                                [HttpException (0x80004005): Session state has created a session id, but cannot save it because the response was already flushed by the application.]
                                System.Web.SessionState.SessionIDManager.SaveSessionID(HttpContext context, String id, Boolean&amp; redirected, Boolean&amp; cookieAdded) +3235276
                                System.Web.SessionState.SessionStateModule.CreateSessionId() +54
                                System.Web.SessionState.SessionStateModule.DelayedGetSessionId() +80
                                System.Web.SessionState.SessionStateModule.ReleaseStateGetSessionID() +19
                                System.Web.SessionState.SessionStateModule.OnReleaseState(Object source, EventArgs eventArgs) +545
                                System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +141
                                System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp; completedSynchronously) +69
                            


    Информация о версии: Microsoft .NET Framework Версия: 4.0.30319; ASP.NET версия: 4.6.1649.1

когда я устанавливаю customErrors mode = "Off" , тогда я получаю эту ошибку, и иногда она возникает не каждый раз,

  1. я также изменяю в global.asax файл и добавляю ниже функцию, но не могу решить проблему

      void Session_Start(object sender, EventArgs e)  
        { 
           string sessionId = Session.SessionID; 
        }
    

Ошибка по-прежнему та же

вот код стороны .NET

        public List<ReportSchedular> GetReportSchedular(string ID){
            List<ReportSchedular> objuser = new List<ReportSchedular>();
            try
            {
                DataSet Data = ReportSchedular.GetReportSchedular(ID);
                if (((Data != null) && (Data.Tables.Count > 0)) && (Data.Tables[0].Rows.Count > 0))
                {

                    foreach (DataRow row in Data.Tables[0].Rows)
                    {
                        ReportSchedular obj = new ReportSchedular
                        {
                            ID = ConvertToInt64(row["ID"]),
                            CompanyName = Convert.ToString(row["CompanyName"]),
                            CompanyID = Convert.ToString(row["CompanyID"]),
                            AutoRepeat = Convert.ToString(row["AutoRepeat"]),
                            Duration = Convert.ToString(row["Duration"]),
                            Email = Convert.ToString(row["Email"]),
                            UserId=Convert.ToInt64(row["UserId"]),
                            PeerCompanyIDs = Convert.ToString(row["PeerCompanyIDs"]),
                            ReportDate = String.Format("{0:MM/dd/yyyy}", Convert.ToDateTime(row["ReportDate"])),
                            SchedulerEmail = Convert.ToString(row["SchedulerEmail"]),
                            PeersName = Convert.ToString(row["PeersName"]),
                            //last_sent = String.Format("{0:MM/dd/yyyy}", Convert.ToDateTime(row["last_sent"])),
                            // below code for to handle a null values of 'last_sent'.
                            last_sent = String.Format("{0:MM/dd/yyyy}", !string.IsNullOrEmpty(row["last_sent"].ToString()) ? Convert.ToString(row["last_sent"]) : null),
                        };
                        objuser.Add(obj);
                    }

                }
                return objuser;

            }
            catch (Exception exception)
            {
                Common.AppendLog("Exception Message: " + exception.Message.ToString() + Environment.NewLine + "Stack Trace: " + exception.StackTrace.ToString() + Environment.NewLine + Environment.NewLine);
                return objuser;
            }
    }
...