Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

ASP.NET Error: Not a valid Win32 FileTime.

Posted on 2011-09-22
4
Medium Priority
?
753 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 1000 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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
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…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

688 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