Solved

ASP.NET Error: Not a valid Win32 FileTime.

Posted on 2011-09-22
4
700 Views
Last Modified: 2014-01-27
Experts,

I'm getting an intermittent error message on one of my sites, it appears to be happening when creating the Forms Authentication ticket, but I am not sure. The message is:

Not a valid Win32 FileTime.

Stack Trace:
at System.DateTime.ToFileTimeUtc() at System.Web.Security.FormsAuthentication.MakeTicketIntoBinaryBlob(FormsAuthenticationTicket ticket) at System.Web.Security.FormsAuthentication.Encrypt(FormsAuthenticationTicket ticket, Boolean hexEncodedTicket) at System.Web.Security.FormsAuthentication.Encrypt(FormsAuthenticationTicket ticket) at BasePage.LoginUser(sanSub thisSub, Boolean persist) in E:\0\2\98\59\2098059\user\2300711\htdocs\App_Code\BasePage.vb:line 315 at _Default.btnQuestSubmit_Click(Object sender, EventArgs e) in E:\0\2\98\59\2098059\user\2300711\htdocs\trial\Default.aspx.vb:line 96 at System.Web.UI.WebControls.Button.OnClick(EventArgs e) at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

Here is the function "LoginUser()", which creates the ticket and authenticates the user, where it appears to be originating, although it looks like the actual error is not triggered by one of my lines of code, but by something built into the forms authentication:

    Public Sub LoginUser(ByVal thisSub As sanSub, Optional ByVal persist As Boolean = True)
        FormsAuthentication.Initialize()
        CurrentSub = thisSub
        Dim Ticket As FormsAuthenticationTicket = New FormsAuthenticationTicket(1, thisSub.SubID, Now, thisSub.SubEnd.AddMonths(1), persist, "", FormsAuthentication.FormsCookiePath)
        Dim hash As String = FormsAuthentication.Encrypt(Ticket)
        Dim cookie As HttpCookie = New HttpCookie(FormsAuthentication.FormsCookieName, hash)

        If (Ticket.IsPersistent) Then
            cookie.Expires = Ticket.Expiration
        End If
        Response.Cookies.Add(cookie)
    End Sub

Open in new window


This is for a subscription based newsletter, and the object "ThisSub" in the function represents a Subscriber object, and "SubEnd' is the date their subscription expires which is a valid date every time.

I have been using this function for years, and only in the last few months has this error started popping up.

Any insight would be greatly appreciated.
0
Comment
Question by:mylescardiff
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 36582298
See if the discussion here helps to solve your problem.

http://www.codeproject.com/KB/aspnet/Forms_Auth_Internals.aspx
0
 
LVL 1

Author Comment

by:mylescardiff
ID: 36582384
That explains how it is supposed to work, but not anything about why this would trigger a filetime error:

Each DateTime value is converted into the equivalent “FileTime” (represented as a long value) and converted to a byte array.

That's pretty much all it says. I'm passing a perfectly valid DateTime value to the ticket.
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 250 total points
ID: 36582401
What is the regional setting on the server?
0
 
LVL 1

Author Comment

by:mylescardiff
ID: 36582435
It's hosted by network solutions, so i don't really know. All I can tell is that it's U.S. East Coast timezone.
0

Featured Post

Quiz: What Do These Organizations Have In Common?

Hint: Their teams ended up taking quizzes, too.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question