Click here to Skip to main content
15,887,267 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: The connection was closed unexpectedly Pin
oujeboland28-Oct-11 7:15
oujeboland28-Oct-11 7:15 
GeneralRe: The connection was closed unexpectedly Pin
Dennis E White28-Oct-11 7:30
professionalDennis E White28-Oct-11 7:30 
GeneralRe: The connection was closed unexpectedly Pin
oujeboland28-Oct-11 21:46
oujeboland28-Oct-11 21:46 
GeneralRe: The connection was closed unexpectedly Pin
Dennis E White29-Oct-11 5:16
professionalDennis E White29-Oct-11 5:16 
GeneralRe: The connection was closed unexpectedly Pin
oujeboland29-Oct-11 20:22
oujeboland29-Oct-11 20:22 
AnswerRe: The connection was closed unexpectedly Pin
jkirkerx28-Oct-11 18:40
professionaljkirkerx28-Oct-11 18:40 
GeneralRe: The connection was closed unexpectedly Pin
oujeboland28-Oct-11 22:12
oujeboland28-Oct-11 22:12 
GeneralRe: The connection was closed unexpectedly Pin
jkirkerx29-Oct-11 7:20
professionaljkirkerx29-Oct-11 7:20 
I may be way off base here, for I really don't see the connection between the XML and creating a HTML page from scratch.

When you develop on your computer, you can test 2 ways, 1 is in the Web Dev, which is a debug version of IIS Server, it's wide open, and has no security features, so you can access anything in your Windows OS. The web dev doesn't care what your doing, it just lets you step through code to fix issues.

The other is to use the IIS Server that you can run in the Windows OS, which does have Security and boundaries, in which you code cannot modify the OS. It cares what you do, and will apply boundaries and borders to your executing code.

As for your code, there is not posted for a through inspection.

With web code, you have to open, read and then close real fast. Because it's multi-user. I suspect that you left something open, or something crashed, and you don't know about it, so the connection closed.

This is the proper code for using XMLTextReader and opening a xml file. It has been tested over time, and can handle up to 3 read and writes per second. I open the file, read it, and destroy the reader. Then I manipulate the data. You have to add Serialize Handlers during the read and write.

Dim DataLocation As String = Nothing
        DataLocation = Context.Server.MapPath("~/App_Data/CompanyInfo/ShippingLocations.xml")

        'XML Data routines go here
        Dim request_serializer As New XmlSerializer(GetType(Shipping_Origin_Data))
        AddHandler request_serializer.UnknownNode, AddressOf serializer_UnknownNode
        AddHandler request_serializer.UnknownAttribute, AddressOf serializer_UnknownAttribute

        Dim Reader As XmlTextReader = Nothing
        Dim XmlRequest As New Shipping_Origin_Data

        Try
            Reader = New XmlTextReader(DataLocation)
            XmlRequest = CType(request_serializer.Deserialize(Reader), Shipping_Origin_Data)
            Reader.Close()
            Reader = Nothing

        Catch ex As Exception
            FirstRecordFlag = True
        End Try


This is the proper code for writing a file to the disk drive with XMLTextWriter. Notice how I open and read the file, and then close it. I manipulate the data, and then I open the file and write it, and destroy all the objects.

VB
'Now Lets Write out the file as a MemoryStream
               Dim serializer As XmlSerializer
               serializer = New XmlSerializer(GetType(Shipping_Origin_Data))

               Dim XmlResponse As New Shipping_Origin_Data
               XmlResponse.Version = "1.4.2"
               XmlResponse.CreationDate = DateTime.Now.ToString("yyyy-MM-dd")
               XmlResponse.Geographic_Record = MyLocation

               'Now we have to write out a file for certification
               Dim response_serializer As XmlSerializer = Nothing
               response_serializer = New XmlSerializer(GetType(Shipping_Origin_Data))

               Dim response_writer As StreamWriter = Nothing
               response_writer = New StreamWriter(DataLocation)
               response_serializer.Serialize(response_writer, XmlResponse)

               response_writer.Close()
               response_writer = Nothing

               request_serializer = Nothing
               serializer = Nothing

Protected Sub serializer_UnknownNode(ByVal sender As Object, ByVal e As XmlNodeEventArgs)

        Dim Context As HttpContext = HttpContext.Current
        'Context.Response.Write("Unknown Node:" & e.Name & ControlChars.Tab & e.Text)

    End Sub
    Protected Sub serializer_UnknownAttribute(ByVal sender As Object, ByVal e As XmlAttributeEventArgs)

        Dim Context As HttpContext = HttpContext.Current
        Dim attr As System.Xml.XmlAttribute = e.Attr
        'Context.Response.Write("Unknown attribute " & attr.Name & "='" & attr.Value & "'")

    End Sub

GeneralRe: The connection was closed unexpectedly Pin
oujeboland29-Oct-11 20:26
oujeboland29-Oct-11 20:26 
QuestionLogin Management Pin
shashiankam27-Oct-11 20:14
shashiankam27-Oct-11 20:14 
AnswerRe: Login Management Pin
Richard MacCutchan27-Oct-11 21:50
mveRichard MacCutchan27-Oct-11 21:50 
GeneralRe: Login Management Pin
shashiankam29-Oct-11 1:19
shashiankam29-Oct-11 1:19 
AnswerRe: Login Management Pin
jkirkerx28-Oct-11 18:48
professionaljkirkerx28-Oct-11 18:48 
Questionvalidate list control 2010 Pin
classy_dog27-Oct-11 12:14
classy_dog27-Oct-11 12:14 
AnswerRe: validate list control 2010 Pin
phil.o27-Oct-11 22:57
professionalphil.o27-Oct-11 22:57 
AnswerRe: validate list control 2010 Pin
jkirkerx28-Oct-11 19:09
professionaljkirkerx28-Oct-11 19:09 
QuestionIssues with Partial Postback / AJAX / Update Panel Pin
jscheponik27-Oct-11 4:42
jscheponik27-Oct-11 4:42 
Questionweb value Pin
sc steinhayse27-Oct-11 3:53
sc steinhayse27-Oct-11 3:53 
AnswerRe: web value Pin
Dennis E White27-Oct-11 4:31
professionalDennis E White27-Oct-11 4:31 
AnswerRe: web value Pin
Abhinav S27-Oct-11 4:32
Abhinav S27-Oct-11 4:32 
AnswerRe: web value Pin
Not Active27-Oct-11 5:23
mentorNot Active27-Oct-11 5:23 
AnswerRe: web value Pin
jkirkerx28-Oct-11 19:40
professionaljkirkerx28-Oct-11 19:40 
QuestionNone Object Oriented Control Pin
Ali Al Omairi(Abu AlHassan)26-Oct-11 20:55
professionalAli Al Omairi(Abu AlHassan)26-Oct-11 20:55 
AnswerRe: None Object Oriented Control Pin
Not Active27-Oct-11 2:43
mentorNot Active27-Oct-11 2:43 
GeneralRe: None Object Oriented Control Pin
Ali Al Omairi(Abu AlHassan)27-Oct-11 4:53
professionalAli Al Omairi(Abu AlHassan)27-Oct-11 4:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.