ASP.NET MVC Framework Preview 2 Bug ?

Last post 03-11-2008 4:14 AM by astaykov. 1 replies.

Sort Posts:

  • ASP.NET MVC Framework Preview 2 Bug ?

    03-10-2008, 4:38 PM
    • Loading...
    • astaykov
    • Joined on 05-17-2007, 7:27 AM
    • Posts 2

    Hello,

    I am playing with the Preview 2 of the MVC Framework and noticed something strange:
    When I use the "Html" property (HtmlHelper Instance) in a ViewPage to render a FORM tag like this:
     <%= Html.Form("MyController", "MyAction") %>
    I end up with this markup:
    <form action="/MyController/MyAction" method="post" >System.Web.Mvc.SimpleForm 

    Please note the "System.Web.Mvc.SimpleForm" - it is not my mistake - it comes out in the markup regardless of the Build Configuration (Debug or Release).
    Is this some bug, or I do something wrong?

    Regards,
    Anton  
     

     

     

    Filed under: ,
  • Re: ASP.NET MVC Framework Preview 2 Bug ?

    03-11-2008, 4:14 AM
    • Loading...
    • astaykov
    • Joined on 05-17-2007, 7:27 AM
    • Posts 2

    Hm,
    After several more scenarios I revealed the  strange, may be, behavior of that extension method.

    We should use <% Html.Form("MyController", "MyAction") %> instead of <%= Html.Form("MyController", "MyAction") %>,
    Because the helper method Form(HtmlHelper, string ControllerName, string ControllerAction) is writing directly onto the Context, instead of returning a string. So when we use the <%= %> syntax, it will first write the output to the current Context, and then will output the type that is writing - in this case System.Web.Mvc.SimpleForm.

    I think this is a strange behavior, because no other helper method (like Button, Hidden, etc.) is writing to the context, but is returning a string.

    Regards,
    Anton
     

    Filed under: ,
Page 1 of 1 (2 items)
Microsoft Communities
Page view counter