ASP.NET/IIS 中的自定义全局标记
我想制作一些自定义标签,可以在 IIS 上的 HTML 中全面使用。我想使用 C#/ASP.NET 实现这些特殊标签。
我想要实现的是,我有一个中央数据库,我在其中存储某些信息,例如服务价格等信息。然后我希望能够在 HTML 中使用特殊标签,这些标签在服务器端进行解析和转换,然后再在客户端显示数据。
我在 IIS 上运行了一些不同的服务,并且我们的主要内容来自闭源 CMD,因此我无法实现 CMS 中的任何核心内容,因此我希望这就像来自 CMS 的内容之后的一层CMS 已生成。
我在闭源 CMS 中可以访问的是更改 web.config 和 Global.asax 中的值。
请就我如何实施此类服务提出建议。我对所有解决方案持开放态度。
I would like to make some custom tags, that can be used all-round in HTML on an IIS. I would like to implement these special tags using C#/ASP.NET.
What I want to achieve, is that I have a central database, where I store certain information, like service prices, and information like that. Then I would like to be able to use special tags in HTML, that are being parsed, and transformed on server side, before displaying the data on the client side.
I have a few different services running on the IIS, and our main content comes from a closed source CMD, so I am not able to implement anything central in the CMS, therefor I would like this to be like a layer after the content from the CMS is generated.
What I have access to in the closed source CMS, is to change values in web.config and Global.asax.
Please come up with suggestions on how I can implement such a service. I am open for all solutions.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您应该查看 HTTP 过滤器,因为这将允许您将您所描述的功能注入到固定 CMS 的响应管道中:
http://msdn.microsoft.com/en-us/magazine/cc301704.aspx
http://msdn.microsoft.com/en-us/library/ff649096.aspx
You should look at HTTP filters as this would allow you to inject functionality such as you describe into the response pipeline of even a fixed CMS:
http://msdn.microsoft.com/en-us/magazine/cc301704.aspx
http://msdn.microsoft.com/en-us/library/ff649096.aspx
我将使用
HttpModule
和Filter
:HttpModule
来选择您要应用Filter
的内容,Filter
来替换您的自定义包含您自己的内容的标签Rick Strahl 写了一篇文章,介绍使用 Response.Filter 来压缩任意页面的输出,其中有其他示例应该得到你开始了。
I'd implement this with a
HttpModule
and aFilter
:HttpModule
to select the content to which you'd like to apply aFilter
Filter
to replace your custom tags with your own contentRick Strahl wrote an article about using
Response.Filter
to compress the output of any page, and there are other examples which should get you started.听起来您想要的是 ASP.NET 用户控件。标记的语法可能类似于:
然后,控件可以访问您的 CMS 并生成浏览器呈现页面所需的 HTML 和/或 JavaScript。
您还可以创建可包含其他控件的模板化控件。
It sounds like what you're after is an ASP.NET User Control. The syntax for your markup might be something like:
The control could then access your CMS and generate HTML and/or JavaScript that the browser needs to render the page.
You can also create templated controls that can contain other controls.