http://fgte.st/SocialCount/examples/
API Calls (GET, PUT, POST,DELETE)
#region API Calls
#region GET
public static HttpResponseMessage CallGETAPI(String uri, IEnumerable<dynamic> Params)
{
try
{
using (HttpClient client = new HttpClient())
{
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
if (HttpContext.Current.Session["Token"] != null && HttpContext.Current.Session["Token"] != "")
client.DefaultRequestHeaders.Add("X-My-Secret-Token", HttpContext.Current.Session["Token"].ToString());
return client.GetAsync(BaseAddress + "api/" + uri).Result;
}
}
catch (Exception ex)
{
LogException("Call GET API ", ex.ToString());
return new HttpResponseMessage() { StatusCode = System.Net.HttpStatusCode.InternalServerError };
}
}
#endregion GET
#region POST
public static HttpResponseMessage CallPOSTAPI(String uri, Object Params)
{
using (HttpClient client = new HttpClient())
{
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
if (HttpContext.Current.Session["Token"] != null && HttpContext.Current.Session["Token"].ToString() != "")
client.DefaultRequestHeaders.Add("X-My-Secret-Token", HttpContext.Current.Session["Token"].ToString());
return client.PostAsJsonAsync(BaseAddress + "api/" + uri ,Params).Result;
}
}
#endregion
#region PUT
public static HttpResponseMessage CallPUTAPI(String uri, Object Params)
{
using (HttpClient client = new HttpClient())
{
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
if (HttpContext.Current.Session["Token"] != null && HttpContext.Current.Session["Token"].ToString() != "")
client.DefaultRequestHeaders.Add("X-My-Secret-Token", HttpContext.Current.Session["Token"].ToString());
return client.PutAsJsonAsync(BaseAddress + "api/" + uri, Params).Result;
}
}
#endregion PUT
#region DELETE
public static HttpResponseMessage CallDeleteAPI(String uri)
{
using (HttpClient client = new HttpClient())
{
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
if (HttpContext.Current.Session["Token"] != null && HttpContext.Current.Session["Token"].ToString() != "")
client.DefaultRequestHeaders.Add("X-My-Secret-Token", HttpContext.Current.Session["Token"].ToString());
return client.DeleteAsync(BaseAddress + "api/" + uri).Result;
}
}
#endregion DELETE
#endregion
#region GET
public static HttpResponseMessage CallGETAPI(String uri, IEnumerable<dynamic> Params)
{
try
{
using (HttpClient client = new HttpClient())
{
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
if (HttpContext.Current.Session["Token"] != null && HttpContext.Current.Session["Token"] != "")
client.DefaultRequestHeaders.Add("X-My-Secret-Token", HttpContext.Current.Session["Token"].ToString());
return client.GetAsync(BaseAddress + "api/" + uri).Result;
}
}
catch (Exception ex)
{
LogException("Call GET API ", ex.ToString());
return new HttpResponseMessage() { StatusCode = System.Net.HttpStatusCode.InternalServerError };
}
}
#endregion GET
#region POST
public static HttpResponseMessage CallPOSTAPI(String uri, Object Params)
{
using (HttpClient client = new HttpClient())
{
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
if (HttpContext.Current.Session["Token"] != null && HttpContext.Current.Session["Token"].ToString() != "")
client.DefaultRequestHeaders.Add("X-My-Secret-Token", HttpContext.Current.Session["Token"].ToString());
return client.PostAsJsonAsync(BaseAddress + "api/" + uri ,Params).Result;
}
}
#endregion
#region PUT
public static HttpResponseMessage CallPUTAPI(String uri, Object Params)
{
using (HttpClient client = new HttpClient())
{
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
if (HttpContext.Current.Session["Token"] != null && HttpContext.Current.Session["Token"].ToString() != "")
client.DefaultRequestHeaders.Add("X-My-Secret-Token", HttpContext.Current.Session["Token"].ToString());
return client.PutAsJsonAsync(BaseAddress + "api/" + uri, Params).Result;
}
}
#endregion PUT
#region DELETE
public static HttpResponseMessage CallDeleteAPI(String uri)
{
using (HttpClient client = new HttpClient())
{
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
if (HttpContext.Current.Session["Token"] != null && HttpContext.Current.Session["Token"].ToString() != "")
client.DefaultRequestHeaders.Add("X-My-Secret-Token", HttpContext.Current.Session["Token"].ToString());
return client.DeleteAsync(BaseAddress + "api/" + uri).Result;
}
}
#endregion DELETE
#endregion
Asp.net Gridview MakeAccessible and OnPreRender and RowDataBound
public static void MakeAccessible(GridView grid)
{
if (grid.Rows.Count <= 0) return;
grid.UseAccessibleHeader = true;
grid.HeaderRow.TableSection = TableRowSection.TableHeader;
if (grid.ShowFooter)
grid.FooterRow.TableSection = TableRowSection.TableFooter;
}
protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
MakeAccessible(recentgrid);
}
protected void recentgrid_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Header)
{
e.Row.Cells[0].Attributes.Add("data-class", "expand");
e.Row.Cells[3].Attributes.Add("data-hide", "phone,tablet");
e.Row.Cells[4].Attributes.Add("data-hide", "phone,tablet");
e.Row.Cells[2].Attributes.Add("data-hide", "phone");
}
}
{
if (grid.Rows.Count <= 0) return;
grid.UseAccessibleHeader = true;
grid.HeaderRow.TableSection = TableRowSection.TableHeader;
if (grid.ShowFooter)
grid.FooterRow.TableSection = TableRowSection.TableFooter;
}
protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
MakeAccessible(recentgrid);
}
protected void recentgrid_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Header)
{
e.Row.Cells[0].Attributes.Add("data-class", "expand");
e.Row.Cells[3].Attributes.Add("data-hide", "phone,tablet");
e.Row.Cells[4].Attributes.Add("data-hide", "phone,tablet");
e.Row.Cells[2].Attributes.Add("data-hide", "phone");
}
}
To trace all activities in project
<webconfig>
<System.web>
<trace pageOutput="true"
enabled="true"
requestLimit="10"
localOnly="false"
mostRecent="true"
traceMode="SortByTime"
/>
<System.web>
<trace pageOutput="true"
enabled="true"
requestLimit="10"
localOnly="false"
mostRecent="true"
traceMode="SortByTime"
/>
permanently delete files
Step1: Press windows key + R
Step2: type CMD
Step3: type cipher/w:c:\
Step4: Press Enter
Step2: type CMD
Step3: type cipher/w:c:\
Step4: Press Enter
IE10 renders in IE7 mode. How to force Standards mode?
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="X-UA-Compatible" value="IE=edge" />
</customHeaders>
</httpProtocol>
</system.webServer>
Search This Blog
Arsip Blog
Powered by Blogger.
Recent
Comment
Author Info
Like This Theme
Popular Posts
-
HTML -------------------------------------------------- < label class = "file-upload" > Browse < asp : FileUpload ...
-
1. Download and add FooTable js, css and image files in the project and reference in the page. 1 2 3 4 < meta ...
-
Create an MVC Web Application Open Visual Studio and create a new C# Web project named "ContosoUniversity". In the Ne...
-
SSL Certification creation ------------------------------------------------- Step1 : Download OpenSSL zip https://www.openssl.org/ St...
-
public class User { public int UserID { get ; set ; } [ Required ( ErrorMessage = "Please Enter Your Name" ...
-
public async Task < IHttpActionResult > GetItemsForFormType () { var result = new List < ItemManagementViewMode...
-
Optimizing for website performance includes setting long expiration dates on our static resources, such s images, stylesheets and JavaSc...
-
Update jquery.js file Every request checking to HTTP to https convertHttps : ((function() { if (window.location.href.toLo...
-
public static void MakeAccessible(GridView grid) { if (grid.Rows.Count <= 0) return; grid.UseAc...
-
<asp:Label ID="lblMessage" runat="server" Text="" ForeColor="Red"></asp:Label> ...
Video Of Day
jishnukanat@gmail.com
Sponsor
Most Popular
-
HTML -------------------------------------------------- < label class = "file-upload" > Browse < asp : FileUpload ...
-
1. Download and add FooTable js, css and image files in the project and reference in the page. 1 2 3 4 < meta ...
-
Create an MVC Web Application Open Visual Studio and create a new C# Web project named "ContosoUniversity". In the Ne...
-
SSL Certification creation ------------------------------------------------- Step1 : Download OpenSSL zip https://www.openssl.org/ St...
-
public class User { public int UserID { get ; set ; } [ Required ( ErrorMessage = "Please Enter Your Name" ...
-
public async Task < IHttpActionResult > GetItemsForFormType () { var result = new List < ItemManagementViewMode...
-
Optimizing for website performance includes setting long expiration dates on our static resources, such s images, stylesheets and JavaSc...
-
Update jquery.js file Every request checking to HTTP to https convertHttps : ((function() { if (window.location.href.toLo...
-
public static void MakeAccessible(GridView grid) { if (grid.Rows.Count <= 0) return; grid.UseAc...
-
<asp:Label ID="lblMessage" runat="server" Text="" ForeColor="Red"></asp:Label> ...