开发者

Generate static web pages from a template as part of ASP.NET Web application build

开发者 https://www.devze.com 2023-01-20 05:21 出处:网络
I\'m building an HTML5 application (with ASP.NET back-end) and i want to develop it in such a way that i can run it locally with all my resources (such js and css) not minified (so i can debug it easi

I'm building an HTML5 application (with ASP.NET back-end) and i want to develop it in such a way that i can run it locally with all my resources (such js and css) not minified (so i can debug it easily). However when i build the final version i want merge and minify the resources. At the same time i want to create several versions of the app targeting different platforms (iPhone, iPad, desktop, etc) by adding appropriate css.

I thought that the final output should be a set of html files (so the get cached nicely). I could use ASPX and just control the output by a query string parameter, but i don't really want to have the form tag on my page.

So the questions are:

  • What are the pros and cons of using static html pages generated from a template versus a dynamic ASPX page? (apart from being able to run on any web server)
  • If ASPX approach g开发者_运维问答ood enough then how can i get rid of the form tag that's required by ASP.NET?

UDPATE

Another factor in favor of static html pages is the fact that the files are served instantly, whereas ASPX may take awhile to load if the app has recycled.

The back-end is ASP.NET 2.0.


What are the pros and cons of using static html pages generated from a template versus a dynamic ASPX page? (apart from being able to run on any web server)

Pros:

  • Less overhead as you no longer have to serve ASP.NET pages through IIS
  • No viewstate, smaller page sizes (as long as your generator or build process removes them)
  • Faster loading times (due to the reasons above), though this could be achieved serving ASP.NET files with output caching.

Cons:

  • You obviously lose the ability to serve truly dynamic pages. This isn't a problem if you're not processing forms or have data that doesn't have to be updated often.

If ASPX approach good enough then how can i get rid of the form tag that's required by ASP.NET?

If you want to use WebForms and serve dynamic pages you can't get rid of it. If you're wondering how to get rid of it after the static html pages are generated, that could be done using an HTML parser simply enough during your build process.


I ended up using aspx pages. I removed form tag and it seemed to work (as long as i didn't use viewstate)

0

精彩评论

暂无评论...
验证码 换一张
取 消