Post data using HTTP in C#

Currently the preferred approach. Asynchronous. Ships with .NET 4.5; portable version for other platforms available via NuGet.

using System.Net.Http;

POST

using (var client = new HttpClient())
{
    var values = new Dictionary<string, string>
    {
       { "thing1", "hello" },
       { "thing2", "world" }
    };

    var content = new FormUrlEncodedContent(values);

    var response = await client.PostAsync("http://www.example.com/recepticle.aspx", content);

    var responseString = await response.Content.ReadAsStringAsync();
}

GET

using (var client = new HttpClient())
{
    var responseString = client.GetStringAsync("http://www.example.com/recepticle.aspx");
}

References
http://stackoverflow.com/questions/4015324/http-request-with-post

Keywords
http , method , get , C# , .NET

ASP.NET MVC exception : Multiple types were found that match the controller named ‘Home’

This error message often happens when you use areas and you have the same controller name inside the area and the root. For example you have the two:

~/Controllers/HomeController.cs
~/Areas/Admin/Controllers/HomeController.cs

In order to resolve this issue (as the error message suggests you), you could use namespaces when declaring your routes. So in the main route definition in Global.asax:

routes.MapRoute(
    "Default",
    "{controller}/{action}/{id}",
    new { controller = "Home", action = "Index", id = UrlParameter.Optional },
    new[] { "AppName.Controllers" }
);

and in your ~/Areas/Admin/AdminAreaRegistration.cs:

context.MapRoute(
    "Admin_default",
    "Admin/{controller}/{action}/{id}",
    new { action = "Index", id = UrlParameter.Optional },
    new[] { "AppName.Areas.Admin.Controllers" }
);

If you are not using areas it seems that your both applications are hosted inside the same ASP.NET application and conflicts occur because you have the same controllers defined in different namespaces. You will have to configure IIS to host those two as separate ASP.NET applications if you want to avoid such kind of conflicts. Ask your hosting provider for this if you don’t have access to the server.

References :
http://stackoverflow.com/questions/7842293/multiple-types-were-found-that-match-the-controller-named-home