Solved

ASP.NET Error: Not a valid Win32 FileTime.

Posted on 2011-09-22
4
568 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
  • 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

777 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