如何在App_Code之外编译C#文件?

时间:2023-01-16 15:48:13

I'd like to stick a class down in my folder hierarchy. The scenario is too trivial to warrant it's own project or separate website. However, I hate to clutter my top-level App_Code with something that's used by a tiny corner of the site.

我想在我的文件夹层次结构中粘贴一个类。这种情况太过微不足道,无法保证自己的项目或单独的网站。但是,我讨厌用我网站上一个小角落使用的东西来混乱我的*App_Code。

Is there a way in web.config to include another file or folder in the compilation process?

web.config中是否有一种方法可以在编译过程中包含另一个文件或文件夹?

2 个解决方案

#1


0  

<configuration>
   <system.web>
      <compilation>
         <assemblies>
            <add assembly="<AssemblyName>, Version=<Version>, Culture=<Culture>, PublicKeyToken=<PublicKeyToken>"/>
         </assemblies>
      </compilation>
   </system.web>
</configuration>

#2


1  

It sounds like you are using the "Web Site" project type. You might consider switching to the "Web Application" project type which works more like a traditional project, allowing you to have a much more flexible folder structure (code can go anywhere you like, and App_Code isn't a special folder).

听起来您正在使用“网站”项目类型。您可以考虑切换到“Web应用程序”项目类型,它更像传统项目,允许您拥有更灵活的文件夹结构(代码可以在任何您喜欢的地方,App_Code不是特殊文件夹)。

This post has a brief discussion and links on the pros/cons of Web Site vs. Web Application projects:

这篇文章简要讨论了网站与Web应用程序项目的优缺点:

http://forums.asp.net/p/1233004/2232697.aspx#2232697

#1


0  

<configuration>
   <system.web>
      <compilation>
         <assemblies>
            <add assembly="<AssemblyName>, Version=<Version>, Culture=<Culture>, PublicKeyToken=<PublicKeyToken>"/>
         </assemblies>
      </compilation>
   </system.web>
</configuration>

#2


1  

It sounds like you are using the "Web Site" project type. You might consider switching to the "Web Application" project type which works more like a traditional project, allowing you to have a much more flexible folder structure (code can go anywhere you like, and App_Code isn't a special folder).

听起来您正在使用“网站”项目类型。您可以考虑切换到“Web应用程序”项目类型,它更像传统项目,允许您拥有更灵活的文件夹结构(代码可以在任何您喜欢的地方,App_Code不是特殊文件夹)。

This post has a brief discussion and links on the pros/cons of Web Site vs. Web Application projects:

这篇文章简要讨论了网站与Web应用程序项目的优缺点:

http://forums.asp.net/p/1233004/2232697.aspx#2232697