public RemoteWidgetController(Page page, string remote_url, string param_prefix, string language)
{
m_page = page;
m_remote_url = remote_url;
m_param_prefix = param_prefix;
m_language = language;
if (m_language.Trim().Length == 0) m_language = "en";
m_items = new List<RemoteWidgetSubject>();
m_widgets = new Hashtable();
// see if we have a POST or an AJAX request for a widget
m_post_target = m_page.Request.QueryString[m_param_prefix + "post"];
m_ajax_target = m_page.Request.QueryString[m_param_prefix + "ajax"];
if (m_post_target != null && m_ajax_target != null) throw new Exception("You may only POST or AJAX-POST to one widget per request");
// strip extra crap out of the url so we can safely build urls
string url = m_page.Request.Url.OriginalString.Split(new char[] { '?' }, 2, StringSplitOptions.RemoveEmptyEntries)[0] + "?";
foreach (string k in m_page.Request.QueryString) {
if (k == null) continue; // foo=bar&baz gives a null k
// copy safe-looking params across - stripping out anything starting with our widget prefix
string v = m_page.Request.QueryString[k];
if (k.StartsWith(m_param_prefix)) continue;
url += m_page.Server.UrlEncode(k) + "=" + m_page.Server.UrlEncode(v) + "&";
}
m_postback_url_prefix = url;
}