在ASPX动态页面呈现 [英] Dynamic Page Rendering in ASPX

查看:236
本文介绍了在ASPX动态页面呈现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很新的C#和.NET,我发现自己面临着一个问题,我不知道在哪个方向,我需要的头。

I'm very new to C# and .NET and I find myself faced with a problem and I'm not sure in which direction I need to head.

我公司与第三方订阅实现系统的许多功能,包括计费和续订。该系统具有在特定事件被触发自动发送电子邮件的功能。例如,每个订阅通过,我们所说,一个续期系列。该系列由几个努力US $ p $垫翻过认购的生活。

My company works with a third party subscription fulfillment system for many functions, including billing and renewals. This system has the capability of automatically sending an email when certain events are triggered. For example, each subscription goes through, what we call, a renewal series. This series consists of several efforts spread accross the life of the subscription.

当订阅资格这一系列的一定的努力,我们可以有一个事件产生,这将导致系统发送HTTP POST请求一个给定的URI与XML有效载荷。端点(.aspx页)接收该请求,处理它,并返回一个响应,在这种情况下,HTML code。然后,该HTML是由执行系统通过电子邮件发送出去。

When a subscription qualifies for a certain effort of this series, we can have an event generated that will cause the system to send a HTTP POST request to a given URI with an XML payload. The endpoint (an .aspx page) receives the request, processes it, and returns a response with, in this case, HTML code. That HTML is then emailed out by the fulfillment system.

我有一些这些.aspx页和运行的创建了一个基本的Web应用程序。每一页背后都有文件中的相应的.cs code。

I have a basic web application created with a few of these .aspx pages up and running. Each page has a corresponding .cs code behind file.

这里就是我的问题才真正开始。在我们的系统中实现,我们只能定义每个事件和产品组合一个端点。所以,不管订阅是在排位赛的时间为它努力,事件本身是相同的。所不同的是,虽然是在HTTP POST请求的XML。这是在XML,我可以告诉已经产生了哪些努力请求。这是非常重要的原因是因为相应的电子邮件的HTML是为每个工作不同。词组它的方式略有不同,应呈现的HTML是不同的,从上到下,为努力1大于努力2.劲道2比努力3不同,等等。

Here's where my question really starts. In our fulfillment system, we can only define one endpoint per combination of event and product. So, no matter which effort a subscription is qualifying for at the time, the event itself is the same. What is different, though, is the XML of the HTTP POST request. It's in that XML that I can tell for which effort the request has been generated. The reason that is important is because the HTML of the corresponding email is different for each effort. To phrase it a slightly different way, the HTML that should be rendered is different, top to bottom, for effort 1 than effort 2. Effort 2 is different than effort 3, and so on.

那么,是什么,我想弄清楚是如何指挥交通。由于所有这些请求会来一个端点,我需要动态地返回正确的HTML为相应的努力。

So, what I'm trying to figure out is how to "direct the traffic". Since all of these requests will come to a single endpoint, I need to dynamically return the correct HTML for the corresponding effort.

在此同一应用不同.aspx页,存在需要根据请求的内容来动态地生成一些内容。在这种情况下,我用了两个占位符控件,一个为每个可能的集文字。然后,在code的后面,因为需要他们的可见属性设置为true或false。

In a different .aspx page in this same app, there is some content that needs to be generated dynamically depending on the contents of the request. In that case, I used two PlaceHolder controls, one for each possible set of text. Then, in the code behind, set their Visible property to true or false as needed.

我这样做辞退,在这种情况下,年初以来有五六个HTML模板和馅他们都到一个页面就混乱和难以维持的想法。

I dismissed the idea of doing that in this case early on since there are five or six HTML templates and stuffing all of them into one page would be messy and hard to maintain.

这是我在哪里,我不知道下一步该怎么做的地步。我有一种感觉,用户控件或自定义控件将是要走的路?但是,就是普通的重定向一个更好的选择?或以上都不是?

This is where I'm at the point that I don't know what to do next. I have a feeling that a User Control or Custom Control is going to be the way to go? But, is plain old redirection a better option? Or none of the above?

推荐答案

在解雇该解决方案是非常接近正确的。然而,有一些东西可以做,以简化它,使维护更加方便。

The solution you dismissed is very close to the correct one. However, there is something you can do to simplify it and make maintenance easier.

我们要在这里做的是建立一个自定义的控制或每个工作的用户控件。这将让你保持code分开的努力,没有在一个地方一起混合的一切。然后,你的整个端点* .aspx页面中包含一个单一的占位符的控制。当处理一个请求,您Page_Load方法将解析您的xml,并找出你需要什么样的努力。然后它会创建适当的控制的一个新实例,它添加到占位符,并且该数据的其余部分传递给控制到结束的处理。

What we want to do here is build a custom control or a user control for each effort. This will let you maintain the code for the efforts separately, without mixing everything together in one place. Then your entire endpoint *.aspx page consists of a single placeholder control. When processing a request, your Page_Load method will parse your xml and figure out what kind of effort you need. It will then create a new instance of the proper control, add it to the placeholder, and pass the rest of the data to the control to finish processing.

由于这里存在的所有控件之间的一些共性(接收XML消息的能力),你可能首先要同时创建一个基本控制了个人努力控制继承。

Because there is some commonality among all the controls here (the ability to receive an xml message), you may first want to also create one base control for the individual effort controls to inherit.

这篇关于在ASPX动态页面呈现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆