473,836 Members | 1,602 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2396
Use a database!

Ray at home

"Kelly Vernon" <kv******@houst on.rr.com> wrote in message
news:0X******** *********@torna do.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******** ********@tk2msf tngp13.phx.gbl. ..
Use a database!

Ray at home

"Kelly Vernon" <kv******@houst on.rr.com> wrote in message
news:0X******** *********@torna do.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.Loc k
open file
append data
close file
Application.Unl ock
....
Jul 22 '05 #4
"Kelly Vernon" wrote in message
news:0X******** *********@torna do.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>00 002</CourseIDNbr>
<CourseName>Pur chasing Systems Training</CourseName>
<SessionNbr>030 1</SessionNbr>
<Day>Tue</Day>
<Date>7/5/2005</Date>
<StartTimeNbr>1 3: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******** *******@TK2MSFT NGP15.phx.gbl.. .
"Kelly Vernon" wrote in message
news:0X******** *********@torna do.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******** ******@TK2MSFTN GP12.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.Loc k
open file
append data
close file
Application.Unl ock
...

Jul 22 '05 #7
"Kelly Vernon" wrote in message
news:FB******** *********@torna do.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>00 002</CourseIDNbr>
: <CourseName>Pur chasing Systems Training</CourseName>
: <SessionNbr>030 1</SessionNbr>
: <Day>Tue</Day>
: <Date>7/5/2005</Date>
: <StartTimeNbr>1 3: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.loc k 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.loc k:
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.Loc k 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.Unl ock 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.ScriptTi meout limit is
reached. If the Server.ScriptTi meout 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.ScriptTi meout 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="VBScr ipt" %>
<%
Application.Loc k
Application("Nu mVisits") = Application("Nu mVisits") + 1
Application("da tLastVisited") = Now()
Application.Unl ock
%>
This application page has been visited
<%= Application("Nu mVisits") %> 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******** ******@TK2MSFTN GP12.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.Loc k 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.Unl ock 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.ScriptTi meout limit is
reached. If the Server.ScriptTi meout 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.ScriptTi meout 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="VBScr ipt" %>
<%
Application.Loc k
Application("Nu mVisits") = Application("Nu mVisits") + 1
Application("da tLastVisited") = Now()
Application.Unl ock
%>
This application page has been visited
<%= Application("Nu mVisits") %> times!

Jul 25 '05 #10

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

Similar topics

19
2224
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 by myself. Recently we have had .NET 1.1 then 2.0 installed and have been told to use it. After reading the books about it, and trying it for a couple of months, I got so mad I decided to write down all of my issues and rants and post them here....
2
2067
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 (non-.Net) if I wanted to fill a list it may look something like this: -------START CODE <%
7
2922
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 database into classes, which are used throughout the application. I have made class collections which, upon reading from the DB, create an instance of the class and store the DB values in there temporarily. My problem is that if user1 looks at...
16
1914
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 of what we will need to adapt to. I have read Microsoft’s “Team Development with Visual Studio .NET and Visual SourceSafe” and tried to set up a development environment as recommended using the “Isolated model”. However, many questions...
13
1152
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 ridiculously over-complicated kludge which causes way more problems than it solves by attempting to turn it into a flat, "event-driven" paradigm for example:
6
2543
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, I'm having trouble writing to the server's event log. Here's some details: Server and workstation both in the same workgroup Logged into server as local Administrator Logged into workstation as a local user that is only in the Users group on
5
2345
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 problem is when we try to deploy it to another machine we receive: ACCESS IS DENIED TO COM1 PORT. We have tried unsuccessfully to get this to work. We have tried the following: 1) Assign the IUSR.... account to Administrators
0
3673
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 delegates were given CDs containing a pre-release version of the .NET framework/SDK and Visual Studio.NET. When was the first version of .NET released? The final version of the 1.0 SDK and runtime was made publicly available around 6pm PST on...
0
3849
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 for the first time versus when the form is posted (sent to the server), which allows you to program accordingly. What are user controls and custom controls? Custom controls: A control authored by a user or a third-party software vendor that...
0
9825
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
9673
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10859
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10560
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10260
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9388
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7795
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6984
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4463
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.