Solved

ASP.NET Error: Not a valid Win32 FileTime.

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now