Solved

ASP.NET Error: Not a valid Win32 FileTime.

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

756 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