Thursday, January 17, 2013

Retrieving all values from POST in asp.net

Here is the code:
<%@ Page Language="C#" CodeFile="~/listen.aspx.cs" Inherits="listenerTest.listen" %>
<%
Response.ClearContent();
Response.ClearHeaders();
Response.Clear();
Response.AddHeader("Content-Type", "text/plain");

if (Request.Form.Count != 0)
{
string all = "";
foreach (string name in Request.Form.AllKeys)
{
string value = Request.Form[name];
// Do something with (name, value).
all += "key:" + name + "value:" + value;
}
}

Response.End();
%>

Thursday, January 3, 2013

Simple Form post from Codebehind C#

Here is the sample code:
private void PostToUrl(string url, string parameters)
{
string URI = url;
string myParameters = parameters;//"param1=value1&param2=value2&param3=value3";

using (WebClient wc = new WebClient())
{
wc.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
string HtmlResult = wc.UploadString(URI, myParameters);
}
}

Select an element from xml file using where clause

Here is the sample xml file
<?xml version="1.0" encoding="utf-8" ?>
<urls>
<url keyword="RA">http://google.com </url>
<url keyword="NC">http://google.com </url>
</urls>

Here is the sample code
XDocument doc=XDocument.Load(Server.MapPath("~/urllist.xml"));
var url = (from ur in doc.Descendants("url")
where ur.Attribute("keyword").Value=="RA"
select ur.Value).ToList();

What is DaemonSet in Kubernetes

 A DaemonSet is a type of controller object that ensures that a specific pod runs on each node in the cluster. DaemonSets are useful for dep...