Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4 > ASP.NET 4 General Discussion
ASP.NET 4 General Discussion For ASP.NET 4 discussions not relating to a specific Wrox book
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 4 General Discussion section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old February 4th, 2011, 07:20 AM
Authorized User
Join Date: Jan 2010
Posts: 31
Thanks: 5
Thanked 2 Times in 2 Posts
Default Invalid length for a Base-64 char array

at System.Convert.FromBase64String(String s) at System.Web.UI.ObjectStateFormatter.Deserialize(Str ing inputString) at System.Web.UI.ObjectStateFormatter.System.Web.UI.I StateFormatter.Deserialize(String serializedState) at System.Web.UI.Util.DeserializeWithAssert(IStateFor matter formatter, String serializedState) at System.Web.UI.HiddenFieldPageStatePersister.Load()

I'm getting this error message mailed to me from my page at http://www.mphhire.co.uk/tool-hire-catalogue.aspx - I'm not sure what's causing it, it might be malicious activity or someone using bad input. However, I'm not too happy about the page as my code is a bit bloated.

I use a repeater for displaying the full hire catalog, but I need the category names displayed with the products nested inside so I use linq to get the data from the different tables.

I then have a listview to display the search results which is hidden unless there is a postback

I could just try adding validation controls but ideally, I would prefer one data control to do the whole lot as I think what I have is quite clunky.


protected void Page_Load(object sender, EventArgs e)
        using (items_catsDataContext myDataContext = new items_catsDataContext())

                var TopCats = from category in myDataContext.categories where category.categoryid >1  //top level category not to be displayed
                select new { catName = category.categoryName, category.tblHireItems };               

            rptCats.DataSource = TopCats;



    protected void btnSearch_Click(object sender, EventArgs e)
        if (!(productSearch.Text == ""))

            rptCats.Visible = false;

            SearchError.Text = "Please enter a search phrase";
    protected void resetSearch_Click(object sender, EventArgs e)
        productSearch.Text = string.Empty;
        rptCats.Visible = true;
and front end

<asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:mphhireConnectionString %>" 
            SelectCommand="sp_searchHireItems" SelectCommandType="StoredProcedure">
                <asp:ControlParameter ControlID="productSearch" Name="searchterm" 
                    PropertyName="Text" Type="String" />

and the stored procedure uses

@searchterm nvarchar(50)
I'm thinking that setting a maximum length of 50 on the text box might be the solution to the error if I have a nvarchar(50) for the stored procedure but I would welcome any thoughts on this. Should I use a validation control in addition to a max length on the textbox?

Similar Threads
Thread Thread Starter Forum Replies Last Post
Strings (differences between an array of char and *char) gabberfrombcn C++ Programming 2 August 30th, 2010 08:02 PM
invalid data string or buffer length?? dlacloche Classic ASP Basics 1 July 21st, 2008 03:40 PM
base 64 data in transform golddog XSLT 4 September 14th, 2007 08:39 AM
Invalid conversion from 'char*' to 'char' deuxmio C++ Programming 3 December 8th, 2006 07:56 AM
invalid column length message cronid SQL Server DTS 3 August 5th, 2006 12:49 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.