简体   繁体   中英

Use WebControl in ASP.NET MVC project

I have a class library that renders a web control (System.Web.UI.WebControls.WebControl). This library is referenced in a lot of classic ASP.NET Web Forms projects like this in the .aspx files:

<foo:MyCustomControl ID="myControl" runat="server" />

Now there is a need to use the same control in some new ASP.NET MVC projects. From what I've read web server controls aren't compatible with ASP.NET MVC because they rely on postbacks and viewstate most of the time. What is the best way to expose this web control to the new mvc applications without changing anything in the current control? Should I expose it as a WCF service somehow?

添加一个WebForm(mycontrol.aspx),像以前一样将控件放入其中,并将结果作为iFrame嵌入到MVC应用程序中。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM