running webform page inside MVC framework

Discussion in 'ASP .Net' started by Guoqi Zheng, Jun 7, 2009.

  1. Guoqi Zheng

    Guoqi Zheng Guest

    I am pretty new to ASP.NET MVC. We have a CMS built in MVC. Is it possible
    to run webform aspx page or user control inside MVC view or masterpage?

    I am thinking as below.

    1. In the webform ASPX or user control, I did not include html header, only
    a form and basic table or div to make it possible to be inserted into other
    page.

    2. In the MVC view, I use Server.Execute("webform1.aspx",true); This will
    execute the webform, and also pass all parameters to it.

    3. In the "webform1.aspx", I rewrite the render event to change <form
    action="webform1.aspx"> to <form action="">. This will make the form
    submitted to current MVC route instead of the webform page itself.

    The first time page load, everything works. However when I do a postback
    from this MVC page (which contains webform page), I got an error of invalid
    viewstate, any one can help for this?

    -----------------------------Exception-----------------------------
    [HttpException (0x80004005): ÎÞ·¨ÑéÖ¤Êý¾Ý¡£]
    System.Web.Configuration.MachineKeySection.GetDecodedData(Byte[] buf,
    Byte[] modifier, Int32 start, Int32 length, Int32& dataLength) +289
    System.Web.UI.ObjectStateFormatter.Deserialize(String inputString) +140

    [ViewStateException: ÎÞЧµÄÊÓͼ״̬¡£
    Client IP: 127.0.0.1
    Port:
    User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.0.10)
    Gecko/2009042316 Firefox/3.0.10 (.NET CLR 3.5.30729)
    ViewState:
    /wEPDwUKLTU2ODgwMzc3NQ9kFgICAw9kFgICAw8PFgIeBFRleHQFEGZpcnN0IHRpbWUgdmFsdWVkZGQne8ZhAy5v8ukhe90/1ZE/Cm54hA==
    Referer: http://localhost:1703/
    Path: /]
    ---------------------------/Exception-------------------------------


    Best regards,

    Guoqi Zheng
    http://www.ureader.com
    Guoqi Zheng, Jun 7, 2009
    #1
    1. Advertising

  2. On Sun, 07 Jun 2009 08:10:29 +0200, Guoqi Zheng <> wrote:

    > The first time page load, everything works. However when I do a postback
    > from this MVC page (which contains webform page), I got an error of
    > invalid viewstate, any one can help for this?


    There is no concept of "post back" or "view state" in ASP.NET MVC. This
    really is the key difference between the two frameworks, and trying to
    work around it would probably be a Bad Idea(tm).

    Read the chapter on ASP.NET MVC vs Web Forms in "Professional ASP.NET MVC
    1.0" from Wrox for more detail. Part of the chapter is available here:

    http://books.google.com/books?id=RWGHqKmnRBwC&pg=PT197

    --
    Joern Schou-Rode
    http://malamute.dk/
    Joern Schou-Rode, Jun 9, 2009
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. DC Gringo
    Replies:
    4
    Views:
    4,803
    mfreidge
    Dec 17, 2007
  2. rmn190
    Replies:
    2
    Views:
    2,330
    Arne Vajhøj
    Jan 10, 2008
  3. Paulo
    Replies:
    3
    Views:
    461
    Peter Bromberg [C# MVP]
    Dec 4, 2008
  4. Crazy Cat
    Replies:
    1
    Views:
    669
    schepp
    Sep 3, 2009
  5. DC Gringo
    Replies:
    3
    Views:
    200
    DC Gringo
    Sep 14, 2004
Loading...

Share This Page