Translate

Wednesday, January 28, 2015

C# Simple HttpClient Console application

In this example we will get content from google.com using the System.Net.Http.HttpClient class

Create a new .net console app in Visual Studio 2012. Add a reference to System.Net.http.dll (.net version 4.0)



Copy paste the code below.

using System;
using System.Net.Http;
using System.Threading.Tasks;

namespace HttpClientTest
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            var httpClient = new HttpClient();

            Task asyncThread = httpClient.GetAsync(
                "https://www.google.com").
                ContinueWith(taskWithResponse =>
                {
                    HttpResponseMessage response = taskWithResponse.Result;
                    Task<string> readTask = response.Content.ReadAsStringAsync();

                    Console.WriteLine(readTask.Result);
                }
                );

            asyncThread.Wait();
        }
    }

}

Sunday, January 25, 2015

Accessing Tomcat manager

To be able to access your tomcat manager app at https://localhost:8443/ add this to
apache-tomcat-7.0.55\conf\tomcat-users.xml

<tomcat-users>
  <role rolename="manager-gui"/>
  <role rolename="manager-script"/>
  <role rolename="manager-jmx"/>
  <role rolename="manager-status"/>
  <role rolename="admin-gui"/>
  <role rolename="admin-script"/>
  <user username="tomcat" password="tomcat" roles="manager-gui,manager-script,manager-jmx,manager-status,admin-gui,admin-script"/>
  </tomcat-users>

Now you can access everything in the manager gui using
username: tomcat
password: tomcat