running webform page inside MVC framework

G

Guoqi Zheng

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
 
J

Joern Schou-Rode

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top