C# 应用程序错误System.Web.HttpResponse.Redirect值不能为null

C# 应用程序错误System.Web.HttpResponse.Redirect值不能为null,c#,url,exception,null,response.redirect,C#,Url,Exception,Null,Response.redirect,只有少数用户单击表单上的“提交”按钮时,我遇到了一个错误 以下是例外情况 在以下位置发生异常:System.Web.HttpResponse.Redirect消息:Value 不能为空。参数名称:url源:System.Web堆栈跟踪:在 System.Web.HttpResponse.Redirect(字符串url,布尔值endResponse, 布尔值(永久) 用户点击子站点,然后我调用一个webservice,它返回一个documentID,然后我将用户重定向到外部站点以开始文档 这是我的

只有少数用户单击表单上的“提交”按钮时,我遇到了一个错误 以下是例外情况

在以下位置发生异常:System.Web.HttpResponse.Redirect消息:Value 不能为空。参数名称:url源:System.Web堆栈跟踪:在 System.Web.HttpResponse.Redirect(字符串url,布尔值endResponse, 布尔值(永久)
用户点击子站点,然后我调用一个webservice,它返回一个documentID,然后我将用户重定向到外部站点以开始文档

这是我的代码,我正在检查URL,以确保它有一个

//If the document was successfully created then the user will be redirected to assure sign to immediately sign the document.
                if (isSuccessfull)
                {
                    //Re Directing the user to immediately sign the document.  In assure sign it is called immediate presentment.
                    //ToDo: When testing change the ProductionBaseUrl to the SandBoxBaseURL
                    var redirectUrl =
                        documentNowSubmit.BuildDocuementSigningUrl(
                            ApplicationSettingsFactory.GetApplicationSettings().ProductionBaseUrl, ui_txtEmailAddress.Text,
                            documentResult[0].Id.ToString(),
                            documentResult[0].AuthToken.ToString(),
                            signatoryListQueryResult, string.Empty);
                    if (redirectUrl != string.Empty)
                    {
                        Response.Redirect(redirectUrl, false); //02/14/2013 Removed the end response true from the redirect.
                        //HttpContext.Current.ApplicationInstance.CompleteRequest(); //Added the complete request call..
                    }
                    else
                    {
                        throw new ArgumentNullException("redirectUrl", "User" + fullName  + "-" + emailAddress + ": Document signing url is empty.");
                    }

                }
                else
                {
                    var additionalInformation = "User name: " + userName + " Document Title: " + documentTitle +
                                                " Template Id: " +
                                                templateId;
                    throw new Exception(
                        "An error has occurred with the submission of your document. With the following additional information: " +
                        additionalInformation + " Please contact the service desk for additional help. " +


  assureSignExceptionMsgs);
                }
我在应用程序错误中的global.asax中捕获错误

它总是进入LogAndClearException

   //----------------------------------------------------------------------
        // NAME: Application_Error
        // CHANGE LOG:
        // Date              Programmer          Description
        //----------------------------------------------------------------------

        //If the last error or associated base exception do not have value, exit immediately.
        if (Server.GetLastError() == null)
        {
            return;
        }


        //Ignore 'A first chance exception of type 'System.Threading.ThreadAbortException' occurred in mscorlib.dll'
        //This happens and is documented by Microsoft because the Server.End() is being called. This can happen when an unauthenticated user tries 
        //to access this site and the Response.Resirect is called or if a Response.Redirect is within a Try-Catch block.
        if (Server.GetLastError().GetBaseException() is System.Threading.ThreadAbortException)
        {
            Server.ClearError();
            return;
        }

        //Log the exception in addition to redirecting to the error page
        LogAndClearException();
    }

无法理解为什么有些用户出现错误而有些用户没有出现错误?

我建议使用
string.IsNullOrEmpty(..)
检查重定向URL,而不是与string.Empty进行比较。

我想

  var redirectUrl = documentNowSubmit.BuildDocuementSigningUrl(..)

在某些情况下返回null

当我进行字符串比较时,我忘记在字符串中添加toLower,以确保它们的大小写相同。我还添加了上述内容