预编译ASP.NET网站项目中的特定目录

发布于 2024-08-14 11:45:24 字数 500 浏览 13 评论 0原文

我有一个 ASP.NET 网站项目,其中混合了可更新页面和不可更改的页面。

我是否可以预编译某些包含不会更新的页面/控件的目录?

如果是这样,我该如何指定这些目录呢?

编辑2009.12.17

我的项目结构如下:

/cms_pages ==>可更新的 .aspx 页面标记为 CompilationMode="never" 并且没有代码文件。

/app_pages ==>带有 .aspx.cs 代码文件的 .aspx 页面。

/controls ==> .ascx 控件与 .ascx.cs 代码文件。

我想“预编译”app_pagescontrols 文件夹。

可以做吗?

I have an ASP.NET website project which has a mixture of updateable pages and pages that do not change.

Is it possible for me to pre-compile certain directories that contain pages/controls that will not be updated?

If so, how could I designate these directories as such?

Edit 2009.12.17

My project is structured like this:

/cms_pages ==> Updateable .aspx pages marked CompilationMode="never" and no code file.

/app_pages ==> .aspx pages with .aspx.cs code file.

/controls ==> .ascx controls with .ascx.cs code file.

I would like to "pre-compile" the app_pages and controls folders.

Is it possible to do?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

待"谢繁草 2024-08-21 11:45:24

您想要使用代码文件编译 ASPX 页面还是仅编译 App_Code 文件夹中的一些 .cs 文件?

如果您只是尝试对某些静态函数或全局对象进行版本控制,您可以编译一个 DLL 并将其保存在 App_Code 文件夹中。

Do you want to compile your ASPX pages with their codefiles or just compile some .cs files in your App_Code folder?

If you're just trying to version control some static functions or global objects you can compile a DLL to keep in your App_Code folder.

倦话 2024-08-21 11:45:24

并非没有很多令人头痛的事情。您现在如何预编译页面?它们必须位于 WAP 中才能工作...因此您不希望预编译的任何内容都可以从项目中删除。

[编辑]

可以手动调用asp.net编译器。但我不推荐这样做。您真正需要做的是将解决方案文件拆分到不同的项目中...将您想要预编译的文件放入 Web 应用程序项目或只是常规类库。然后在您的网站中添加对此 WAP 的项目引用。

Not without a lot of headaches. How are you precompiling the pages now? They must be in a WAP for this to work... so anything you DON'T want precompiled just leave out of the project.

[Edit]

It's possible to manually call the asp.net compiler. But I don't recommend this. What you really need to do is split up your solution files into different projects... put the files you want pre-compiled into a Web Application Project or just a regular class library. Then in your Web Site add a project reference to this WAP.

亚希 2024-08-21 11:45:24

难道你不能将所有控件(可能还有其他任何东西)预编译到程序集中,然后你可以通过 myAssembly.myControl

 Dim assembly As Reflection.Assembly = Reflection.Assembly.LoadFrom(Server.MapPath(Virtual path to assembly))

Dim myControlType As Type = assembly.GetType 访问它们
Dim myControl As UserControl = LoadControl(myControlType, Nothing)
myPanel.Controls.Add(myControl )

或者

Dim myControl As Control = LoadControl(virtual path to control)
myPanel.Controls.Add(myControl )

希望这有帮助..

Couldn't you just pre-compile all of the controls (and probably anything else) into an assembly then you can access them through myAssembly.myControl

 Dim assembly As Reflection.Assembly = Reflection.Assembly.LoadFrom(Server.MapPath(Virtual path to assembly))

Dim myControlType As Type = assembly.GetType
Dim myControl As UserControl = LoadControl(myControlType, Nothing)
myPanel.Controls.Add(myControl )

Or

Dim myControl As Control = LoadControl(virtual path to control)
myPanel.Controls.Add(myControl )

Hope this helps..

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文