简体   繁体   English

在应用程序中托管asp.net页面

[英]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 目标是使用应用内托管的模板(可能是使用卡西尼文件)生成一些html报告和html电子邮件

so the report files will be saved in app_home\\Report\\Templates*.MyReport file 因此报表文件将保存在app_home \\ Report \\ Templates * .MyReport文件中

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 该应用程序将允许选择报告(.aspx)页面,并使用cassini / asp.net托管API对其进行加载,并处理一些自定义标记以填充数据

the resultant html can be viewed in the webbrowser control or can be emailed as html emails 生成的html可以在webbrowser控件中查看,也可以通过html电子邮件发送

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. AFAIK,您不能在您的应用程序中分发Cassini。 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. 还有其他桌面Web服务器,但它们都不与asp.net 100%兼容。我认为,您的解决方案实施起来太复杂了。

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. 我个人喜欢上面提到的StringTemplate选项,但实际上您可以在桌面应用程序中托管ASP.NET运行时。

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 West Wind Technologies的 Rick Strahl给出了如何进行设置的详细示例: 使用ASP.Net Runtime通过动态HTML脚本扩展桌面应用程序

Here are a couple of other examples: 这是另外两个例子:

Other alternatives 其他选择

Alternative 1 选择1

One simple solution would be making simple replacements in the template HTML (using you own processor, and you will be ready to go. 一种简单的解决方案是在模板HTML中进行简单的替换(使用您自己的处理器,您就可以使用了。)

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 选择2

Use a templating engine like StringTemplate (look for the C# implementation). 使用诸如StringTemplate之类的模板引擎(查找C#实现)。 This CodeProject article is a good intro to the subject 此CodeProject文章很好地介绍了该主题

Alternative 3 选择3

If you want something more advanced (if your users can take it) I would investigate adding scripting to your app (IronPhyton, IronRuby) 如果您想要更高级的功能(如果您的用户可以使用),我将研究向您的应用程序添加脚本(IronPhyton,IronRuby)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM