locked
context.Response.Write RRS feed

  • Question

  • User1203305613 posted

    First time when I execute the statement 

    context.Response.Write(msg),it doesn't err.

    Second time when we execute  context.Response.Write,it throws the below error,please suggest on how to fix it. 

    <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><soap:Fault><soap:Code><soap:Value>soap:Receiver</soap:Value></soap:Code><soap:Reason><soap:Text xml:lang="en">Server was unable to process request. ---&gt; Data at the root level is invalid. Line 1, position 1.</soap:Text></soap:Reason><soap:Detail /></soap:Fault></soap:Body></soap:Envelope>

    context.Response.Write(msg)

    Thursday, January 25, 2018 11:35 AM

Answers

All replies

  • User475983607 posted

    My best guess is there is a SOAP serialization error  or there an exception.  We cannot see your code so we can only guess.  You'll need to troubleshoot a bit, consider using proper error handling to capture errors and the Visual Studio debugger to debug the code base.  Also, it is extremely unusual to manually serialize a SOAP response as the framework automatically handles SOAP serialization. 

    I suspect you have design issues.  Can you explain the design and post code that reproduces the issue?

    Thursday, January 25, 2018 11:47 AM
  • User1203305613 posted

    Thanks ,Its a file upload code.First iteration it doesn't fail the second iteration it fails.

    Dim uploadPath = ConfigurationManager.AppSettings("FileUploadFolder")
    If Not Directory.Exists(uploadPath) Then
    Directory.CreateDirectory(uploadPath)
    End If
    Dim postedFile = context.Request.Files(0)
    Dim files = postedFile.FileName.Split("\\")
    Dim fileName = files(files.Length - 1)

    Dim folderDir = Path.Combine(uploadPath, "XXX" & context.Session("XXXID"))
    If Not Directory.Exists(folderDir) Then
    Directory.CreateDirectory(folderDir)
    End If
    postedFile.SaveAs(Path.Combine(folderDir, fileName))
    Dim msg = "{"
    msg &= String.Format("error:'{0}', ", String.Empty)
    msg &= String.Format("upfile:'{0}' ", fileName)
    msg &= "}"
    context.Response.Write(msg)

    Thursday, January 25, 2018 2:43 PM
  • User475983607 posted

    The original post shows a SOAP fault.  The new post shows code returning a JSON formatted response.  

    My best guess is you are not showing the code that caused the error and/or there is still information missing from your post.

    Try using the Visual Studio debugger to troubleshoot your code.

    https://msdn.microsoft.com/en-us/library/y740d9d3.aspx

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, January 25, 2018 3:41 PM
  • User1203305613 posted

    Mgebhard , Yes that was a SOAP error message ,thrown as a alert in Javascript ,it took me sometime to figure it out,your guess is correct, how do I debug Javascript with breakpoints in browser any easy way or tips?

    Sunday, February 4, 2018 1:22 PM
  • User475983607 posted

    All modern browser have developer tools which allows client side debugging.  Just press F12.

    Internet Explorer 

    https://msdn.microsoft.com/en-us/library/gg589507(v=vs.85).aspx

    Chrome

    https://developers.google.com/web/tools/chrome-devtools/javascript/

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, February 4, 2018 1:52 PM