简体   繁体   中英

Webforms in class library in asp.net

I am making a class library in asp.net , is there any possibility to add web forms in class library ( content view files with their code-behind ) so i can run , only with a simple method in the CALLER PROJECT ,a whole web app (thanks to this class library) . I searched and i found i can't but If not , is there any near solution which can solve this problem ?

Thanks !

is there any possibility to make a class library as a web app "template" that we can use every time we call it in another project

A "class library" project, in Visual Studio terms, is strictly namespaces and classes - no web forms or controls allowed. And you're right, these projects are easily shared among sites by leaving them in a common source control repository or similar.

In an "ASP.NET Web Forms Web Application" project, you can reduce duplication by moving as much "code behind" code as possible to class libraries, which can then be shared among your team(s). You could even theoretically implement a lot of page/control functionality as "base classes" stored in class libraries and then inherited in aspx.cs and master.cs "code behind" files.

You could also move as much "code front" as possible into Custom User Controls which could be shared across projects by linking source control to a common repository.

But I don't think there's a good way to "share" .master and .aspx files. You could set up a basic website, keep it in a common place, and let people copy/paste it for new projects. But I don't know of a useful way to share that UI code among multiple web app projects.

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