简体   繁体   中英

hosting asp.net pages within the app

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

最好将xslt用于此类任务-您可以将数据模型序列化为xml文档,然后可以将具有xsl模板的xml文档转换为html。

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.

Edit

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:

Other alternatives

Alternative 1

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>

Alternative 2

Use a templating engine like StringTemplate (look for the C# implementation). This CodeProject article is a good intro to the subject

Alternative 3

If you want something more advanced (if your users can take it) I would investigate adding scripting to your app (IronPhyton, IronRuby)

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