Design A
- site A wrap the user control into web service
- site B call web service to get html content
- site B implement both memory cache and cache file to fail back on in case web service call failed. when failing, it trys to load from memory cache first, if there is no content in memory cache, then load it from cache file. when next time a web service call is successful, update memory cache and cache file
pro of Design A:
- very reliable as both memory cache and cache file are available for fall back
cons if Design A:
- site A need to be careful in implementing user control, can't assume some page information like session is available is httprequest
- complex logic in site B to implement fall back workflow
Design B
- Site A wrap user control in a regular aspx page, using javascript document.write to emit content
- Site B consume content by reference to this page as a javascript source
pro of design B:
- easy to implemet on both sides
cons of design B
- no fallback logic, when site A is done, it screw up site B as well
Both wraping solution can't solve the issue if the content need to post back to itself after submit. For example, if a user control has some code behind logic after submit, it won't be available in both wrapped version.
Source code:
Design A at Site A:
HeaderControl hc = (HeaderControl)p.LoadControl("~/UserControls/" + ControlName);Design B at site A:
hc.IsSecure = IsSecure;
hc.IsOLSMenu = true;
hc.Page_Load(null, null); //call page_load to load mennu
hc.RenderControl(htmlWriter);
StringWriter sw = new StringWriter();
Page p = new Page();
HtmlForm f = new HtmlForm();
p.Controls.Add(f);
Header h = (Header)p.LoadControl("~/controls/header.ascx");
p.Controls[0].Controls.Add(h);
Server.Execute(p, sw, false);
Design B at site B:
<script language="javascript" src="http://ta-homecorporate.progressive.com/scripts/headerwrapperjs.aspx"></script>
No comments:
Post a Comment