在应用程序中托管 ASP.NET 页面

发布于 2024-07-26 19:07:08 字数 300 浏览 4 评论 0原文

目标是使用应用程序中托管的模板(可能使用 cassini)生成一些 html 报告和 html 电子邮件,

以便报告文件将保存在 app_home\Report\Templates*.MyReport 文件

该应用程序将允许选择报告 (.aspx) 页面,使用 cassini/asp.net 托管 api 加载它,处理一些自定义标记以填充数据,

生成的 html 可以在网络浏览器控件中查看,也可以作为 html 通过电子邮件发送电子邮件

有更好的方法吗? 另外,有关使用卡西尼号的任何指示都会很棒

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

冰葑 2024-08-02 19:07:08

据我所知,您无法将 Cassini 与您的应用程序一起分发。 还有其他桌面 Web 服务器,但没有一个与 ASP.NET 100% 兼容
在我看来,你的解决方案太复杂而难以实施。

编辑

我从这篇文章中了解到那个

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

Rick Strahl 在West Wind Technologies 提供了如何设置的详细示例:< a href="http://www.west-wind.com/presentations/aspnetruntime/aspnetruntime.asp" rel="nofollow noreferrer">使用 ASP.Net 运行时通过动态 HTML 脚本扩展桌面应用程序< /p>

以下是其他几个示例:

其他替代方案

替代方案 1

一个简单的解决方案是在 HTML 模板中进行简单的替换(使用您自己的处理器,您就可以开始使用了。

类似这样的:

<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>

替代方案 2

使用模板引擎,例如 StringTemplate (查找 C# 实现)。 com/KB/codegen/DotNetCodeGeneration.aspx" rel="nofollow noreferrer">这篇 CodeProject 文章 是对该主题的一个很好的介绍

替代方案 3

如果您想要更高级的东西(如果您的用户可以接受)我会调查将脚本添加到您的应用程序(IronPhyton、IronRuby)

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)

_畞蕅 2024-08-02 19:07:08

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

It is better to use xslt for such tasks - you can serialize you data model into an xml document then you can transform xml document with an xsl template into html.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文