简体   繁体   中英

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. I know I can do this using Post Build events. 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

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. 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

If this folder is included to your VS project,it will automatically get copied to your build output folder.

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

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 .

What you can do is set the path 应用初始化模块

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