ViewPost InvalidCastException

Topics: Developer Forum
Sep 8, 2009 at 8:15 PM

I have a new, unmodified installation of TheBeerHouse_MVC.

I am getting the following error message:

"System.InvalidCastException was unhandled by user code
  Message="Specified cast is not valid."
  Source="App_Web_3fcx4gtm"
  StackTrace:
       at ASP.views_forum_viewpost_aspx.__RenderContent2(HtmlTextWriter __w, Control parameterContainer) in r:\VS2008\Projects\TheBeerHouse_MVC\TheBeerHouse\Views\Forum\ViewPost.aspx:line 6
       at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
       at System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
       at System.Web.UI.Control.Render(HtmlTextWriter writer)
       at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
       at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter)
       at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
       at ASP.views_shared_site_master.__Render__control1(HtmlTextWriter __w, Control parameterContainer) in r:\VS2008\Projects\TheBeerHouse_MVC\TheBeerHouse\Views\Shared\Site.Master:line 45
       at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
       at System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
       at System.Web.UI.Control.Render(HtmlTextWriter writer)
       at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
       at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter)
       at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
       at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
       at System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
       at System.Web.UI.Page.Render(HtmlTextWriter writer)
       at System.Web.Mvc.ViewPage.Render(HtmlTextWriter writer)
       at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
       at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter)
       at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
       at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
  InnerException:
"

 

Oct 6, 2009 at 12:48 AM
Edited Oct 6, 2009 at 8:54 AM

I've had the same error.

You should to correct code in ViewPost.aspx:

instead this line <% var userVote = (int)ViewData["userVote"]; %>

you need to write this one: <%int userVote = int.Parse(ViewData["userVote"].ToString());%>

I did so and now all's OK.

And there is one more solution: http://thebeerhouse.codeplex.com/Thread/View.aspx?ThreadId=62489

Oct 7, 2009 at 2:38 AM

Thank you for your response. You have referenced 2 runtime error corrections in this post:

ThreadID=68317 - ViewPost.aspx

ThreadID=62489 - ForumContoller.cs

I have also noticed minor issues, such as in this thread:

http://p2p.wrox.com/book-asp-net-mvc-website-programming-problem-design-solution-isbn-9780470410950/76282-html-content-editor-html-encode.html

The Advanced View of the Issue Tracker allows us to filter issues by release. It is very unfortunate for TheBeerHouse community that the issues posted to the Issue Tracker section of this project have not been assigned to their appropriate release - especially now that there are 4 separate BeehHouse projects being published within this one CodePlex project workspace.

Do you know if a list of all known errors with the 2.0 Production - MVC May 18 2009 release has been published?

TIA!

 

Oct 7, 2009 at 7:34 PM

No, unfortunately I don't know it. And thank that you mentioned about several releases. I've heard only about one.

Good luck with BeerHouse!