Comparing Date and Showing New or Old

  • Thread starter Thread starter Richard
  • Start date Start date
R

Richard

In a forum I made in ASP Classic I had the following code.
-------------------------------
If Session("dtmLastVisit") = "" AND
Request.Cookies("DigiForum")("LastVisit") <> "" Then
Session("dtmLastVisit") = CDate(Request.Cookies("DigiForum")("LastVisit"))
Response.Cookies("DigiForum")("LastVisit") = CDbl(Now())
Response.Cookies("DigiForum").Expires = DateAdd("yyyy", 1, Now())
ElseIf Session("dtmLastVisit") = "" Then
Session("dtmLastVisit") = Now()
End If

If isNumeric(Request.Cookies("DigiForum")("LastVisit")) Then
If CDate(Request.Cookies("DigiForum")("LastVisit")) < DateAdd("n", -5,
Now()) Then
Response.Cookies("DigiForum")("LastVisit") = CDbl(Now())
Response.Cookies("DigiForum").Expires = DateAdd("yyyy", 1, Now())
End If
Else
Response.Cookies("DigiForum")("LastVisit") = CDbl(Now())
Response.Cookies("DigiForum").Expires = DateAdd("yyyy", 1, Now())
End If
-------------------------------

This code made sure each time when a user revisited a page and there had
been a new post, a "new" would show itself.
The problem I have is making this code work in ASP .NET. I was wondering if
someone could give me an url on where
this topic is discussed in ASP .NET or maybe can help me convert this code
into VB for .NET.

Thx in advance,

Richard
 
Hi Richard,

From your description and the code , most of them are Session and Cookie
manipulation. Generally, all the functions for Session and Cookie still
remains in ASP.NET and provide more convenient interfaces. Such as the
Buildin Session object and the Request.Cookies collection. You can
reference them in the MSDN's documentation. And since the Cookie need to
specify Expire date, in asp.net , we use the DateTime class rather than the
CDate in asp. Here are some tech articles on using cookie and session in
ASP.NET

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechar
t/html/vbtchaspnetcookies101.asp

http://msdn.microsoft.com/library/en-us/dnaspnet/html/asp12282000.asp?frame=
true

also, some further resources on migrating from asp to asp.net:

#Converting ASP to ASP.NET
http://msdn.microsoft.com/library/en-us/dndotnet/html/convertasptoaspnet.asp
?frame=true

#Migrating to ASP.NET: Key Considerations
http://msdn.microsoft.com/library/en-us/dnaspp/html/aspnetmigrissues.asp?fra
me=true

#ASP to ASP.NET Migration Assistant
http://msdn.microsoft.com/asp.net/using/migrating/aspmig/aspmigasst/default.
aspx

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
 
Hi Richard,

Did Steven's suggestion help on this issue? If you need further assistance,
please feel free to post here.

Regards,

Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
Back
Top