Click here to Skip to main content
15,906,329 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: asp.net Pin
pmarfleet2-Feb-08 22:31
pmarfleet2-Feb-08 22:31 
AnswerRe: asp.net Pin
John-ph2-Feb-08 23:17
John-ph2-Feb-08 23:17 
GeneralRe: asp.net Pin
Jintal Patel4-Feb-08 23:46
Jintal Patel4-Feb-08 23:46 
GeneralServerside Viewstate problems Pin
Member 40915372-Feb-08 9:25
Member 40915372-Feb-08 9:25 
GeneralA developing problem Pin
mehrdadc482-Feb-08 7:43
mehrdadc482-Feb-08 7:43 
AnswerRe: A developing problem Pin
Venkatesh Mookkan3-Feb-08 15:53
Venkatesh Mookkan3-Feb-08 15:53 
GeneralRe: A developing problem Pin
Expert Coming3-Feb-08 17:54
Expert Coming3-Feb-08 17:54 
QuestionDateTime.Now() Not updating or is being cached? Pin
Expert Coming2-Feb-08 7:10
Expert Coming2-Feb-08 7:10 
Have what we believe to be an issue with caching in master pages or IIS or C# in general. We have a site where we give X number of resources to a user per day. In this example we are giving them 100 Wheat for every Farm they have per 24 hour period.

We store the last DateTime.Now.Tick value in their user profile in the SQL database. When they refresh a page, it reads the current DateTime.Now.Tick value and compare the two and then do the following math to compute hoe much more production they should have.

dLogs = ((dtNow.Ticks - lLastUpdateTicks) * production / (864000000000.0 * Globals.PERIOD));

This formula of course works but I have to refresh the page twice to get the proper values. The first time I refresh it gives me just a few ticks update worth of the Wheat. Here is the begining of the function...

<br />
	public GameEvents(int UserID)<br />
	{<br />
        intUserID = UserID;<br />
        dtNow = DateTime.Now;<br />
<br />
        //Get the Last Time the user updated<br />
        SqlDataReader rdr = null;<br />
        SqlConnection connection = null;<br />
<br />
        try<br />
        {<br />
            string szConnection = System.Configuration.ConfigurationManager.AppSettings["SQLConnection"];<br />
<br />
            connection = new SqlConnection(szConnection);<br />
<br />
            string szQuery = "SELECT LastUpdate FROM King WHERE (ID = @UserID)";<br />
<br />
            SqlCommand cmd = new SqlCommand(szQuery, connection);<br />
            cmd.Parameters.AddWithValue("@UserID", intUserID);<br />
<br />
            connection.Open();<br />
<br />
            rdr = cmd.ExecuteReader();<br />
<br />
            while (rdr.Read())<br />
            {<br />
                lLastUpdateTicks = rdr.GetInt64(rdr.GetOrdinal("LastUpdate"));<br />
            }<br />


So we get the current DateTime and the value out of the database of our last update and then do the following math to compute the resources they should have gained as follows...

<br />
<br />
dLogs = ((dtNow.Ticks - lLastUpdateTicks) * production / (864000000000.0 * Globals.PERIOD));<br />
<br />


We should not have to refresh twice to get a complete update. We know it is the DateTime issue and believe it is a cache issue or something like that as the resources are updated a few ticks with the first refresh which tells me that it is not just failing to run the code. Then on the second refresh it updates to where it should be as far as number of resources.

Guess the net of the question is: "Does master pages or IIS or whatever it is cache this DateTime.Now() and not go out to the system each and every time?" If not what else coudld be the problem!

Any help would be greatly appreciated!!!

The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo

GeneralRe: DateTime.Now() Not updating or is being cached? Pin
Guffa3-Feb-08 7:11
Guffa3-Feb-08 7:11 
GeneralRe: DateTime.Now() Not updating or is being cached? Pin
Expert Coming3-Feb-08 17:50
Expert Coming3-Feb-08 17:50 
Generalerror uploading to server Pin
Boshkash2-Feb-08 1:13
Boshkash2-Feb-08 1:13 
GeneralRe: error uploading to server Pin
pmarfleet2-Feb-08 3:12
pmarfleet2-Feb-08 3:12 
QuestionHow to use Resource.resx file in my soution. Pin
Sasmi2-Feb-08 1:12
Sasmi2-Feb-08 1:12 
AnswerRe: How to use Resource.resx file in my soution. Pin
Preyatham2-Feb-08 5:05
Preyatham2-Feb-08 5:05 
AnswerRe: How to use Resource.resx file in my soution. Pin
John-ph3-Feb-08 0:08
John-ph3-Feb-08 0:08 
Questionhow i can make a list box to show the data in the columns type Pin
jagan1232-Feb-08 0:34
jagan1232-Feb-08 0:34 
AnswerRe: how i can make a list box to show the data in the columns type Pin
pmarfleet2-Feb-08 3:05
pmarfleet2-Feb-08 3:05 
Generalasp.net Pin
arivazhagi1-Feb-08 20:31
arivazhagi1-Feb-08 20:31 
GeneralRe: asp.net Pin
Michael Sync1-Feb-08 21:25
Michael Sync1-Feb-08 21:25 
GeneralRe: asp.net Pin
pmarfleet1-Feb-08 23:06
pmarfleet1-Feb-08 23:06 
GeneralRe: asp.net Pin
Colin Angus Mackay2-Feb-08 5:04
Colin Angus Mackay2-Feb-08 5:04 
GeneralRe: asp.net Pin
dilipv3-Feb-08 20:03
dilipv3-Feb-08 20:03 
GeneralSending Email Pin
.NET- India 1-Feb-08 20:15
.NET- India 1-Feb-08 20:15 
GeneralRe: Sending Email Pin
Michael Sync1-Feb-08 21:21
Michael Sync1-Feb-08 21:21 
GeneralRe: Sending Email Pin
.NET- India 1-Feb-08 22:35
.NET- India 1-Feb-08 22:35 

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.