开发者

How to mix ASP.NET Webforms and ASP.NET MVC together?

I appreciate if someone instruct or give me a helpful link in how this 2 technologies work together side by side. In routeing where I get the most difficulties, when I give link a MVC page to Web Form with Web.sitemap datasource i开发者_高级运维t works fine in some cases but except those runat server tags error.


It doesn't seem to me like you are trying to run webforms side-by-side with MVC. It seems like you want to use Webforms code in an MVC page, which is something very different.

side-by-side means you might have one page that is webforms, and another page that is MVC in the same site. That is doable.

Making Webforms code work in an MVC page is far more tricky, and in most cases won't work. While it's true that you can use the webforms view engine, and even have a code behind with an MVC page, you will find that much of the Webforms infrastructure isn't there. You can't use Viewstate, and most controls rely on viewstate. So you can only use controls that do not rely on Viewstate (there aren't a lot of those kinds of controls).

I think you need to be more clear about what you are trying to do.


From my own experience this is a bad idea. On my team, we are currently in the middle of a migration for a product built in Webforms to MVC, so there are places where we have to deal with this temporarily tell we can successfully rewrite all the Webforms functionality. However, the information in this blog post will be helpful for you, there is a sample project as well.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜