开发者

Compile ASPX in WinForms App

I'm writing a WinForms application that sends email messages (like a mail merge).

I'd like to use ASP.Net's rendering engine to render the HTML bodies of the messages.

What's the simplest way to get the rendered output of a single ASPX page without the entire ASP.Net runtime?

To make things harder, I'd prefer to compile the ASPX at runtime so 开发者_Go百科that it can be modified without rebuilding the application. However, this is not a requirement; if it's too difficult, I'll give up on it.


Rick Strahl posted an article how to do this at this location: http://www.west-wind.com/presentations/aspnetruntime/aspnetruntime.asp. I know there is a way to call some internal .NET Framework methods but I can't remember what they are off hand.


You may want to consider using a templating lib like NVelocity. Using the WebForms rendering engine in this manner is a bit overkill and hackish at best.

As an aside: keep in mind that HTML in email sucks. Even the most elementary of CSS is ignored by the majority of email clients. If you want my advice, KISS and save your sanity: if you're going to automate emails, send only plain text.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜