简体   繁体   English

在ASP.NET MVC项目中使用WebControl

[英]Use WebControl in ASP.NET MVC project

I have a class library that renders a web control (System.Web.UI.WebControls.WebControl). 我有一个呈现Web控件的类库(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: .aspx文件中的许多经典ASP.NET Web Forms项目都引用了此库:

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

Now there is a need to use the same control in some new ASP.NET MVC projects. 现在,在某些新的ASP.NET MVC项目中需要使用相同的控件。 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. 据我所知,Web服务器控件与ASP.NET MVC不兼容,因为它们大多数时候都依赖于回发和viewstate。 What is the best way to expose this web control to the new mvc applications without changing anything in the current control? 在不更改当前控件中任何内容的情况下将此Web控件公开给新的mvc应用程序的最佳方法是什么? Should I expose it as a WCF service somehow? 我应该以某种方式将其公开为WCF服务吗?

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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