473,386 Members | 1,832 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

ASP: Having troubles with multiple people writing to XML file at the same time

I have a standard ASP page that appends to an xml page.

Currently if there is more than one person attempting to append to the same
XML file at a time. One user will have the ability to append, and the other
user will append nothing.

Is there a way to avoid this from happening? For example. Lets say the user
opens up a cached version of the page then append to the actual file. For
some reason I remember reading about something like that, but just can't
recall.

Thanks,

Kelly
Jul 22 '05 #1
9 2372
Use a database!

Ray at home

"Kelly Vernon" <kv******@houston.rr.com> wrote in message
news:0X*****************@tornado.texas.rr.com...
I have a standard ASP page that appends to an xml page.

Currently if there is more than one person attempting to append to the
same XML file at a time. One user will have the ability to append, and the
other user will append nothing.

Is there a way to avoid this from happening? For example. Lets say the
user opens up a cached version of the page then append to the actual file.
For some reason I remember reading about something like that, but just
can't recall.

Thanks,

Kelly

Jul 22 '05 #2
I wish we could, but they didn't allow that option. :(
Kelly

"Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
message news:%2****************@tk2msftngp13.phx.gbl...
Use a database!

Ray at home

"Kelly Vernon" <kv******@houston.rr.com> wrote in message
news:0X*****************@tornado.texas.rr.com...
I have a standard ASP page that appends to an xml page.

Currently if there is more than one person attempting to append to the
same XML file at a time. One user will have the ability to append, and
the other user will append nothing.

Is there a way to avoid this from happening? For example. Lets say the
user opens up a cached version of the page then append to the actual
file. For some reason I remember reading about something like that, but
just can't recall.

Thanks,

Kelly


Jul 22 '05 #3
Kelly Vernon wrote:
I have a standard ASP page that appends to an xml page.

Currently if there is more than one person attempting to append to the same
XML file at a time. One user will have the ability to append, and the other
user will append nothing.

Is there a way to avoid this from happening? For example. Lets say the user
opens up a cached version of the page then append to the actual file. For
some reason I remember reading about something like that, but just can't
recall.


Serialize access to the file by requiring the user to first access the
Application object (or a specific Application variable) before updating
the file. So something like:
....
Application.Lock
open file
append data
close file
Application.Unlock
....
Jul 22 '05 #4
"Kelly Vernon" wrote in message
news:0X*****************@tornado.texas.rr.com...
:I have a standard ASP page that appends to an xml page.
:
: Currently if there is more than one person attempting to append to the
same
: XML file at a time. One user will have the ability to append, and the
other
: user will append nothing.
:
: Is there a way to avoid this from happening? For example. Lets say the
user
: opens up a cached version of the page then append to the actual file. For
: some reason I remember reading about something like that, but just can't
: recall.

Hi Kelly... and howdy neighbor... I'm in Houston too.

It's best not to use your real email address in Usenet unless you like spam.

How long is the XML file open that causes this to be such a problem. Have
you timed it?

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
Jul 22 '05 #5
Good afternoon Roland,

Enjoying the our weather? :D

Towards the email, I only use it for this newsgroup, I don't check the
actual email address. I have other accounts I use there. Thank you for the
advice.

As for the XML file. It gets broken down like so...

<?xml version="1.0" ?>
<Courselog>
<Entry>
<AICCNbr>999998</AICCNbr>
<EmpID>99801</EmpID>
<CourseIDNbr>00002</CourseIDNbr>
<CourseName>Purchasing Systems Training</CourseName>
<SessionNbr>0301</SessionNbr>
<Day>Tue</Day>
<Date>7/5/2005</Date>
<StartTimeNbr>13:32:35</StartTimeNbr>
<EndTimeNbr>14:23:52</EndTimeNbr>
<CourseScoreNbr>87</CourseScoreNbr>
</Entry>
</Courselog>

The log gets created in two parts...

the first time someone takes a course, they create an entry and all but the
last two nodes (EndTimeNbr & CourseScoreNbr) are created as well.

When they complete the test, it runs through a function and searches for an
AICCNbr match. When it finds the match it appends EndTimeNbr &
CourseScoreNbr nodes to the associated Entry node.

As one individual the file does great, but I wound up doing a stress test
with 6 people in the group trying to submit their test information at the
same time and the results were not pretty for two of them.

I'm just trying to cover any gaps or possible bugs that could occur.

I saw one idea from another post, the application lock. I'll have to
research that one. Are there any other methods that might prove effective?

Thanks,

Kelly

"Roland Hall" <nobody@nowhere> wrote in message
news:%2***************@TK2MSFTNGP15.phx.gbl...
"Kelly Vernon" wrote in message
news:0X*****************@tornado.texas.rr.com...
:I have a standard ASP page that appends to an xml page.
:
: Currently if there is more than one person attempting to append to the
same
: XML file at a time. One user will have the ability to append, and the
other
: user will append nothing.
:
: Is there a way to avoid this from happening? For example. Lets say the
user
: opens up a cached version of the page then append to the actual file.
For
: some reason I remember reading about something like that, but just can't
: recall.

Hi Kelly... and howdy neighbor... I'm in Houston too.

It's best not to use your real email address in Usenet unless you like
spam.

How long is the XML file open that causes this to be such a problem. Have
you timed it?

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation -
http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp

Jul 22 '05 #6
Hi Michael,

Thanks for your help. I've got a couple of questions for you in relation to
the application lock/unlock method I hope you don't mind helping me
understand more.

What happens when another user is trying to append to the xml when the first
person is appending? I mean would the user just sit there and wait until the
file is available? (do while loop or something)

Thanks,

Kelly

"Michael D. Kersey" <md******@hal-pc.org> wrote in message
news:u2**************@TK2MSFTNGP12.phx.gbl...
Kelly Vernon wrote:
I have a standard ASP page that appends to an xml page.

Currently if there is more than one person attempting to append to the
same XML file at a time. One user will have the ability to append, and
the other user will append nothing.

Is there a way to avoid this from happening? For example. Lets say the
user opens up a cached version of the page then append to the actual
file. For some reason I remember reading about something like that, but
just can't recall.


Serialize access to the file by requiring the user to first access the
Application object (or a specific Application variable) before updating
the file. So something like:
...
Application.Lock
open file
append data
close file
Application.Unlock
...

Jul 22 '05 #7
"Kelly Vernon" wrote in message
news:FB*****************@tornado.texas.rr.com...
: Good afternoon Roland,

Afternoon.

: Enjoying the our weather? :D

I think we have extra on my side of town.

: Towards the email, I only use it for this newsgroup, I don't check the
: actual email address. I have other accounts I use there. Thank you for the
: advice.

I have a few throw aways myself.

: As for the XML file. It gets broken down like so...
:
: <?xml version="1.0" ?>
: <Courselog>
: <Entry>
: <AICCNbr>999998</AICCNbr>
: <EmpID>99801</EmpID>
: <CourseIDNbr>00002</CourseIDNbr>
: <CourseName>Purchasing Systems Training</CourseName>
: <SessionNbr>0301</SessionNbr>
: <Day>Tue</Day>
: <Date>7/5/2005</Date>
: <StartTimeNbr>13:32:35</StartTimeNbr>
: <EndTimeNbr>14:23:52</EndTimeNbr>
: <CourseScoreNbr>87</CourseScoreNbr>
: </Entry>
: </Courselog>
:
: The log gets created in two parts...
:
: the first time someone takes a course, they create an entry and all but
the
: last two nodes (EndTimeNbr & CourseScoreNbr) are created as well.
:
: When they complete the test, it runs through a function and searches for
an
: AICCNbr match. When it finds the match it appends EndTimeNbr &
: CourseScoreNbr nodes to the associated Entry node.
:
: As one individual the file does great, but I wound up doing a stress test
: with 6 people in the group trying to submit their test information at the
: same time and the results were not pretty for two of them.
:
: I'm just trying to cover any gaps or possible bugs that could occur.
:
: I saw one idea from another post, the application lock. I'll have to
: research that one. Are there any other methods that might prove effective?

I use the Application.lock myself when tracking visitors to one of my sites.
Applications do allow you to thread the process but it takes a performance
hit. There is also a timeout, which is why I asked how long the process
takes but you cannot capture the error.

This will give you a little info on application.lock:
http://msdn.microsoft.com/library/de...0dc206b46a.asp

I have a version of my shopping cart that only uses XML files. I never
experience this issue because I never share files when they write to the
file. Each person has their own cart file, receipt file, etc. However,
they do share files when they read from them like with product files,
postalcode lookup files, shipping rates files, etc. but that should impose a
limitation since they're just being read.

Another possible solution would be to let each one write to their own XML
file and just have an app that would consolidate for reporting, etc.

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
Jul 22 '05 #8
Kelly wrote:
Hi Michael,

Thanks for your help. I've got a couple of questions for you in relation to
the application lock/unlock method I hope you don't mind helping me
understand more.

What happens when another user is trying to append to the xml when the first
person is appending? I mean would the user just sit there and wait until the
file is available? (do while loop or something)


"Yes" is the short answer; no loop is necessary.

When working with a new feature/object/method be sure to read the
documentation (especially what's in asterisks(*) below):

Application.Lock Method
The Lock method blocks other clients from modifying the variables stored
in the Application object, ensuring that only one client at a time can
alter or access the Application variables. If you do not call the
Application.Unlock method explicitly, the server unlocks the locked
Application object when the .asp file ends or times out.

Lock()

Parameters
This method has no parameters.

Return Values
This method has no return values.

Remarks
A lock on the Application object persists for a very short time because
the application object is unlocked when the page completes processing or
times out.

*********
If one page locks the application object and a second page tries to do
the same while the first page still has it locked, the second page will
wait for the first to finish, or until the Server.ScriptTimeout limit is
reached. If the Server.ScriptTimeout limit is reached, the following ASP
error is returned which cannot be captured:
*********

HTTP 500.100 - Internal Server Error - ASP error
Internet Information Services
Active Server Pages, ASP 0113 (0x80004005)
The maximum amount of time for a script to execute was exceeded.
You can change this limit by specifying a new value for the property
Server.ScriptTimeout or by changing the value in the IIS administration
tools.

Note:
A page does not need to lock the application object to edit the
application collection. If one page tries to edit the application
collection without locking and a second page also tries to edit the
collection, no error is sent by IIS and the Application object ends up
in an inconsistent state.

Example Code
In the following example, the Lock method prevents more than one client
at a time from accessing the variable NumVisits. If the application had
not been locked, two clients could simultaneously try to increment the
variable NumVisits.

<%@ Language="VBScript" %>
<%
Application.Lock
Application("NumVisits") = Application("NumVisits") + 1
Application("datLastVisited") = Now()
Application.Unlock
%>
This application page has been visited
<%= Application("NumVisits") %> times!
Jul 22 '05 #9
Thanks Michael,

Sorry for the mucho delay in response. I had some big issues arise which
couldn't be avoided. I hope you understand, and equally I'm very fortunate
for your help.

From this stand point, it got shelved for a little bit as we had to shift
our focus to course creation at the office. When it lightens up, I'll jump
into trying out this idea of the application lock you suggested.

Ciao,

Kelly

"Michael D. Kersey" <md******@hal-pc.org> wrote in message
news:OT**************@TK2MSFTNGP12.phx.gbl...
Kelly wrote:
Hi Michael,

Thanks for your help. I've got a couple of questions for you in relation
to the application lock/unlock method I hope you don't mind helping me
understand more.

What happens when another user is trying to append to the xml when the
first person is appending? I mean would the user just sit there and wait
until the file is available? (do while loop or something)


"Yes" is the short answer; no loop is necessary.

When working with a new feature/object/method be sure to read the
documentation (especially what's in asterisks(*) below):

Application.Lock Method
The Lock method blocks other clients from modifying the variables stored
in the Application object, ensuring that only one client at a time can
alter or access the Application variables. If you do not call the
Application.Unlock method explicitly, the server unlocks the locked
Application object when the .asp file ends or times out.

Lock()

Parameters
This method has no parameters.

Return Values
This method has no return values.

Remarks
A lock on the Application object persists for a very short time because
the application object is unlocked when the page completes processing or
times out.

*********
If one page locks the application object and a second page tries to do the
same while the first page still has it locked, the second page will wait
for the first to finish, or until the Server.ScriptTimeout limit is
reached. If the Server.ScriptTimeout limit is reached, the following ASP
error is returned which cannot be captured:
*********

HTTP 500.100 - Internal Server Error - ASP error
Internet Information Services
Active Server Pages, ASP 0113 (0x80004005)
The maximum amount of time for a script to execute was exceeded.
You can change this limit by specifying a new value for the property
Server.ScriptTimeout or by changing the value in the IIS administration
tools.

Note:
A page does not need to lock the application object to edit the
application collection. If one page tries to edit the application
collection without locking and a second page also tries to edit the
collection, no error is sent by IIS and the Application object ends up in
an inconsistent state.

Example Code
In the following example, the Lock method prevents more than one client at
a time from accessing the variable NumVisits. If the application had not
been locked, two clients could simultaneously try to increment the
variable NumVisits.

<%@ Language="VBScript" %>
<%
Application.Lock
Application("NumVisits") = Application("NumVisits") + 1
Application("datLastVisited") = Now()
Application.Unlock
%>
This application page has been visited
<%= Application("NumVisits") %> times!

Jul 25 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
by: DotNetIsHorrible | last post by:
I write CRUD database applications for a living for an audience of about 100 users per application using classic ASP. I maintain and frequently change on user's request 22 different applications...
2
by: Daniel | last post by:
I'm new to .Net and all of its abilities so I hope this makes sense. Basically I'm confused on when is the appropriate time to use web forms controls vs. regular HTML. For example in ASP...
7
by: jsale | last post by:
I'm currently using ASP.NET with VS2003 and SQL Server 2003. The ASP.NET app i have made is running on IIS v6 and consists of a number of pages that allow the user to read information from the...
16
by: Linus | last post by:
Being a ASP developer for a consultant company thinking of starting developing with ASP.NET I have read literally hundreds of web pages and posts in discussion forums on the Internet to get an idea...
13
by: John Rivers | last post by:
Here is an example of what I am talking about: asp.net takes what is a very simple, powerful and flexible concept, http request/response with html for presentation and turns it into a...
6
by: rekaeps | last post by:
We are developing an ASP.NET 2.0 (C#) application, and I'm having troubles sending e-mail from the server when accessing the web site from a separate client computer. Also, in the same scenario,...
5
by: Franklin M. Gauer III | last post by:
Hi All, I've written an ASP.NET application (webservice) that does simple serial communications via the .NET 2.0 SerialComm object. The application runs fine on my development machine. The...
0
by: shamirza | last post by:
· When was .NET announced? Bill Gates delivered a keynote at Forum 2000, held June 22, 2000, outlining the .NET 'vision'. The July 2000 PDC had a number of sessions on .NET technology, and...
0
by: shamirza | last post by:
· What is view state and use of it? The current property settings of an ASP.NET page and those of any ASP.NET server controls contained within the page. ASP.NET can detect when a form is requested...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.