The goal is to generate some html reports and html emails using templates hosted within the app perhaps using cassini
so the report files will be saved in app_home\Report\Templates*.MyReport file
The app would allow a report (.aspx) page to be selected, loads it using cassini/asp.net hosting api processing some custom markup to populate the data
the resultant html can be viewed in the webbrowser control or can be emailed as html emails
Is there a better way ? Also any pointers on using cassini as such would be great
AFAIK you can not distribute Cassini with your apps. There are other desktop webserver, but non of them are 100% compatible with asp.net
In my opinion, your solution will be too complicated to implement.
I learn from this post that
I personally like the StringTemplate option mentioned above, but you can actually host the ASP.NET runtime in a desktop application.
Rick Strahl over at West Wind Technologies has a detailed example of how to set it up: Using the ASP.Net Runtime for extending desktop applications with dynamic HTML Scripts
Here are a couple of other examples:
- Code Project: Using ASP.NET Runtime in Desktop Applications
- MSDN Magazine: ASP. NET Client-side Hosting with Cassini -- The nuts and bolts of how to use the ApplicationHost class.
- Andrew Peter's Blog: In-process ASP.NET MVC Web Form View Rendering
One simple solution would be making simple replacements in the template HTML (using you own processor, and you will be ready to go.
Something like this:
<table>
<tr>
<th>Name</th>
<th>Phone</th>
</tr>
<tr>
<th>$Name</th> <!-- you should run a replace with $Name to the name -->
<th>$Phone</th>
</tr>
Use a templating engine like StringTemplate (look for the C# implementation). This CodeProject article is a good intro to the subject
If you want something more advanced (if your users can take it) I would investigate adding scripting to your app (IronPhyton, IronRuby)