473,624 Members | 2,119 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can Time Ticks uniquely identify IIS requests?

hi,
i'm generating PDF files from crystal reports in my .Net 1.1 web site, and
saving them to disk for the user to download in their own time.

the format i'm currently using is: FileName_<DateT ime.Now.Ticks>. PDF

there is a relatively low level of concurrent users on this site, but i am a
little concerned that two requests could happen within the same tick,
resulting in a filename clash and overwrite. is this possible? the docs
say a tick is 100 nanoseconds, which is a very short time i know. i have a
reasonable understanding of memory and disk access times, and the IIS/.Net
request life cycle, which would tell me that because disks are so relatively
slow, being measured in milliseconds, that IIS couldn't perform two
synchronous writes in the same tick. my nagging doubt is that two
simultaneous requests could run to the point in code where the file names
are calculated within the same tick, and then the disk I/O could be
executed.

i like having the Ticks in the file name because it is somewhat useful to me
that they are sequential. but if it is at all risky then i would change to
using a GUID in the filename.

any ideas? i know this is overkill to be concerned like this but i'm
interested anyway :)
many thanks in advance

tim mackey
Sep 11 '06 #1
3 1707
Hi,

Tim_Mac wrote:
hi,
i'm generating PDF files from crystal reports in my .Net 1.1 web site, and
saving them to disk for the user to download in their own time.

the format i'm currently using is: FileName_<DateT ime.Now.Ticks>. PDF

there is a relatively low level of concurrent users on this site, but i am a
little concerned that two requests could happen within the same tick,
resulting in a filename clash and overwrite. is this possible? the docs
say a tick is 100 nanoseconds, which is a very short time i know. i have a
reasonable understanding of memory and disk access times, and the IIS/.Net
request life cycle, which would tell me that because disks are so relatively
slow, being measured in milliseconds, that IIS couldn't perform two
synchronous writes in the same tick. my nagging doubt is that two
simultaneous requests could run to the point in code where the file names
are calculated within the same tick, and then the disk I/O could be
executed.
If you want to avoid concurrent access to a critical resource (in that
case, that would be the clock), you must use the lock statement. For
example, you could use a class to generate the file names and save the
files, and enclose the critical section in

lock ( this )
{
// ...
}

This will ensure a sequential execution.

However, the requests will be processed in sequential order too, so the
risk is zero IMHO.

If you really, really want to make sure that the ID is unique *and*
incrementing, why don't you simply add an index?

private static long lIndexOfFile = 0;

and then

string strFileName = "FileName_"
+ DateTime.Now.Ti cks + lIndexOfFile++ + ".PDF";

HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Sep 11 '06 #2
Hi Tim,

I would recommend to use GUID in the filename since DateTime.Now.Ti cks is
not guaranteed to be unique.

By the way, is it supported in Crystal Reports to write the generated PDF
file to a stream instead of a file? If it's supported, then you may write
the PDF output the ASP.NET Response's output stream directly without using
a temporary file. Since Crystal Reports is not supported by Microsoft (see
http://support.microsoft.com/kb/100368/en-us for more info), you may have
to contact Crystal Reports for it.

Sincerely,
Walter Wang (wa****@online. microsoft.com, remove 'online.')
Microsoft Online Community Support

=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your reply
promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no rights.

Sep 12 '06 #3
hi,
Laurent, thanks for the tip on using lock, i hadn't considered that
approach.
i think i'll just go with the GUIDs as Walter has suggested. it will give me
slightly better security in terms of malicious users trying to guess the URL
of a temp file. i clear them out every day with a script but even still, my
user population isn't very trustworthy!

Walter i was originally streaming the exported Crystal Reports to the Http
response as you suggested, but i found that very large reports (1000 page
PDFs) caused major problems both on server and client, hanging requests etc.
since i moved to a file based approach i have not had any of these problems
so i trust it a lot more. it also allows users to download the file in
their own time, i can show the status message and provide a hyperlink to
download the file.

thanks again for your help.
tim
"Walter Wang [MSFT]" <wa****@online. microsoft.comwr ote in message
news:Oc******** ******@TK2MSFTN GXA01.phx.gbl.. .
Hi Tim,

I would recommend to use GUID in the filename since DateTime.Now.Ti cks is
not guaranteed to be unique.

By the way, is it supported in Crystal Reports to write the generated PDF
file to a stream instead of a file? If it's supported, then you may write
the PDF output the ASP.NET Response's output stream directly without using
a temporary file. Since Crystal Reports is not supported by Microsoft (see
http://support.microsoft.com/kb/100368/en-us for more info), you may have
to contact Crystal Reports for it.

Sincerely,
Walter Wang (wa****@online. microsoft.com, remove 'online.')
Microsoft Online Community Support

=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your
reply
promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no
rights.

Sep 12 '06 #4

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

Similar topics

2
1417
by: kj | last post by:
In an earlier thread, JKrugman posted the following quote: > ...the purpose of XML namespaces is to uniquely identify element > and attribute names. Unprefixed attribute names can be uniquely > identified based on the element type to which they belong, so > there is no need identify them further by including them in an > XML namespace. In fact, the only reason for allowing attribute > names to be prefixed is so that attributes...
0
1219
by: Ross | last post by:
Hello everybody, When I try to configure my data adapter for ODBC I get the error "Could not determine which columns uniquely identify the rows for "Shipments"." This is for my update and delete statements. I dont understand what is wrong. I have a primary key in my Access database. It is not my table because I tried others, what am I doing wrong, or can anybody help me generate the Delete and update commands required for the...
2
2871
by: muser8 | last post by:
What is the best way in which to uniquely identify anonymous visitors to an asp.net website? I'd like to create on online poll, but I want to guard against people hitting the refresh button, scripting posts to the web form, deleting cookies, ect… Does anyone have any ideas or know where I might find any good online resources? TIA, Sean
0
1203
by: bazzer | last post by:
im trying to access a microsoft access database from an asp.net webform. but when i use the OdbcDataAdapter config wizard i get the following errors: *Generated UPDATE statement -could not determine which columns uniquely identify the rows for "Customers" *Generated DELETE statement
1
1834
by: Anoop Nair | last post by:
Hi I am developing scripts in C# which can be used to test windows based applications. I use Win32 API's to perform click operations etc. To uniquely identify a control in a window rather than using absolute position of a control I have been using Control-ids and captions of the control. But I found scenarios where the control-id was dynamic and the control didn't have a caption. What I mean by caption is the text of the control. A...
1
1557
by: 01423481d | last post by:
Hi all Here is a segment of code used to find out all running processes Imports System.Diagnostics .... Dim myProcesses() As Process Dim myProcess As Process
6
4001
by: Amit Bhatia | last post by:
Hi, I am not sure if this belongs to this group. Anyway, my question is as follows: I have a list (STL list) whose elements are pairs of integers (STL pairs, say objects of class T). When I create a new object of class T, I would like to check if this object already exists in the list: meaning one having same integers. This can be done in linear time in a list, and probably faster if I use STL Set instead of list. I am wondering however if...
10
4493
by: Frankie | last post by:
It appears that System.Random would provide an acceptable means through which to generate a unique value used to identify multiple/concurrent asynchronous tasks. The usage of the value under consideration here is that it is supplied to the AsyncOperationManager.CreateOperation(userSuppliedState) method... with userSuppliedState being, more or less, a taskId. In this case, the userSuppliedState {really taskId} is of the object type,...
6
12789
by: Ryan Liu | last post by:
Hi, If I want to uniquely identify a computer. I can read CPU ID or Mac Address. I heard, but is this true: some BIOS can block CPU ID from being read? (In this case, will I get an exception, null or empty string for method managementObject.Properties?) So maybe Mac address is better way. But when I read Mac address for my laptop, I got:
0
8234
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, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8677
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
8474
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
7158
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 project—planning, coding, testing, and deployment—without 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...
0
5563
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();...
0
4079
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4174
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2605
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
2
1482
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.