简体   繁体   English

ASP.NET从动态页面创建静态HTML文件

[英]Asp.Net create static HTML file from dynamic page

I have a CSS folder and I want that when I build the project it should be copied to my build folder. 我有一个CSS文件夹,我希望在构建项目时将其复制到我的构建文件夹中。 I know I can do this using Post Build events. 我知道我可以使用Post Build事件来做到这一点。 However I don't know how to achieve the following: 但是我不知道如何实现以下目标:

I have an action /MyController/DynamicPage I want that when I build my project this action's method must execute dynamically and spit out the HTML generated by executing the URL in DynamicPage.html 我有一个动作/MyController/DynamicPage我希望在构建项目时必须动态执行该动作的方法,并吐出通过执行DynamicPage.html中的URL生成的HTML。

I want this to happen on building the project / solution. 我希望在构建项目/解决方案时能够做到这一点。 I explored Build Events but I am not sure if post build event can help me execute this type of custom code. 我浏览了Build Events但是不确定post build event可以帮助我执行这种类型的自定义代码。 Is there any way to achieve the above? 有什么办法可以达到上述目的?

Thanks so much. 非常感谢。

I have a CSS folder and I want that when I build the project it should be copied to my build folder 我有一个CSS文件夹,我想在构建项目时将其复制到我的构建文件夹中

If this folder is included to your VS project,it will automatically get copied to your build output folder. 如果此文件夹包含在VS项目中,它将自动复制到生成输出文件夹中。

I have an action /MyController/DynamicPage I want that when I build my project this action's method must execute dynamically and spit out the HTML generated by executing the URL in DynamicPage.html 我有一个动作/ MyController / DynamicPage,我希望在构建项目时必须动态执行该动作的方法,并吐出通过执行DynamicPage.html中的URL生成的HTML。

if you want to happen with build,you should probably write a custom build task ,check this for more details 如果您想进行构建,则可能应该编写自定义构建任务,请检查此内容以获取更多详细信息

If you do not want to do this but would like to achieve the same after deployment(assuming your website runs inside IIS or IIS Express),You can also look at Application Initialization Module .With Application initialzation,IIS server will make sure when the application is deployed and started ,it will make a request to a configurable URL (in this case /MyController/DynamicPage) .Please have a look at this . 如果您不想执行此操作,但希望在部署后实现相同的功能(假设您的网站在IIS或IIS Express中运行),则还可以查看应用程序初始化模块 。通过应用程序初始化 ,IIS服务器将确保何时应用程序部署并启动,它将使一个可配置的URL的请求(在这种情况下/ myController的/ DynamicPage)。请看看这个

What you can do is set the path 您能做的就是设定路径 应用初始化模块

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

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