HTTP Error 500.19 and error code : 0x80070021

Got precisely the same error and came to this question. As @SpaceBison mentioned in comments, this answer describes the solution – https://stackoverflow.com/a/12867753/404099. I spotted it too late and it misses some steps. This is what worked for me: Windows Server 2012, IIS 8.5. Should work for other versions too. Go to server manager, click add … Read more

Exposing localhost to the internet via tunneling (using ngrok): HTTP error 400: bad request; invalid hostname

Troubleshot this issue with ngrok. In the words of inconshrevable, some applications get angry when they see a different host header than expected. Running the following command should fix the problem: ngrok http [port] -host-header=”localhost:[port]” Depending on the version, you may also want to try: ngrok http [port] –host-header=”localhost:[port]”

Accessing Session Using ASP.NET Web API

MVC For an MVC project make the following changes (WebForms and Dot Net Core answer down below): WebApiConfig.cs public static class WebApiConfig { public static string UrlPrefix { get { return “api”; } } public static string UrlPrefixRelative { get { return “~/api”; } } public static void Register(HttpConfiguration config) { config.Routes.MapHttpRoute( name: “DefaultApi”, routeTemplate: … Read more

ServiceStack vs ASP.Net Web API [closed]

They have very similar use-cases, as the lead maintainer for the ServiceStack project I have a good insight into ServiceStack’s advantages and the many natural benefits of its message-based design. ServiceStack has been around since 2008 as an OSS-run project from its inception with a single goal of promoting the correct design and implementation of … Read more

How do I set a cookie on HttpClient’s HttpRequestMessage

Here’s how you could set a custom cookie value for the request: var baseAddress = new Uri(“http://example.com”); var cookieContainer = new CookieContainer(); using (var handler = new HttpClientHandler() { CookieContainer = cookieContainer }) using (var client = new HttpClient(handler) { BaseAddress = baseAddress }) { var content = new FormUrlEncodedContent(new[] { new KeyValuePair<string, string>(“foo”, “bar”), … Read more

Where is HttpContent.ReadAsAsync?

It looks like it is an extension method (in System.Net.Http.Formatting): HttpContentExtensions Class Update: PM> install-package Microsoft.AspNet.WebApi.Client According to the System.Net.Http.Formatting NuGet package page, the System.Net.Http.Formatting package is now legacy and can instead be found in the Microsoft.AspNet.WebApi.Client package available on NuGet here.

Returning binary file from controller in ASP.NET Web API

Try using a simple HttpResponseMessage with its Content property set to a StreamContent: // using System.IO; // using System.Net.Http; // using System.Net.Http.Headers; public HttpResponseMessage Post(string version, string environment, string filetype) { var path = @”C:\Temp\test.exe”; HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK); var stream = new FileStream(path, FileMode.Open, FileAccess.Read); result.Content = new StreamContent(stream); result.Content.Headers.ContentType = new MediaTypeHeaderValue(“application/octet-stream”); … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)