Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9139619
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:24:40+00:00 2026-06-17T09:24:40+00:00

Please help, I’m trying to self-host a web api. When the same controller is

  • 0

Please help, I’m trying to self-host a web api.

When the same controller is hosted on a web project, and run on dev, via F5, everything works well.

However now I’m trying to self-host the same, I’m getting 411 and 404. 411, when I use Fiddler to connect, 404 when I’m attempting to connect via another library.

This is the console app that’s supposed to host the service:

class Program
{        
    static int portNumber;



    static void Main(string[] args)
    {
        portNumber = 8089;

        var config = new HttpSelfHostConfiguration(
            string.Format("http://localhost:{0}", portNumber));

        config.Routes.MapHttpRoute(
                "API Default", "api/{controller}/{id}",
                new { id = RouteParameter.Optional });

        using (var server = new HttpSelfHostServer(config))
        {

            var test = new RetrieveGuidService().Execute(Unit.Instance);

            server.OpenAsync().Wait();

            Console.ReadLine();
        }
    }
}

This is what my controller looks like, it doesn’t do anything it’s just a test.

public class RetrieveGuidServiceController : ApiController
{
    public virtual Guid PostExecute(Unit request)
    {
        IQueryService<Unit,Guid> queryService = new RetrieveGuidService();
        return queryService.Execute(request);
    }
}

And here’s how I’m attempting to access it via fiddler:

My Fiddler Pic

The same works when the service is hosted on a web project. I have followed this tutorial almost to the letter: asp.net WebApi self host tutorial which includes running nugget scripts, adding dependencies, etc.

What am I still missing?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T09:24:41+00:00Added an answer on June 17, 2026 at 9:24 am

    The 411 is because you didn’t put the Content-Length header. Even if you are not sending content you need to include Content-Length: 0.

    Regarding having the Controller in the correct assembly I have had inconsistent behaviour. In some projects it seems to work in other it doesn’t. Not sure what I am doing wrong. I have a project here that does both Web Host and Self-Host with all the controllers in a different assembly and it works just fine.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please help me rectify this problem. I am not able to run my project
please help me. I want know about what types of flags to run an
Please help me, I'm trying to find some documentation about pre-installed applications at Android.
please help me out for the below problem, i am trying since long time(3
Please help me I am new to Maven. I am trying to generate a
Please help me, as I will go mad with this soon: When I run
Please help me... i am trying to update my database from VB.net. It shows
please help me resolve this problem: There is an ambient MSMQ transaction. I'm trying
Please help me implement access control lists for my PHP web application. I'm using
Please help me out guys. I'm just trying to declare a simple result tree

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.