question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

All routes not found on MacOS

See original GitHub issue

Hi, I’m make an app work fine on Windows. But on MacBook display “Not found (Not found)” any route. Here is my code: ` static HttpRequestService request; static void Main(string[] args) { Server s = new Server(“127.0.0.1”, 19000, false, DefaultRoute);

        s.Routes.Static.Add(WatsonWebserver.HttpMethod.GET, "/app.js", async (ctx) => {
            ctx.Response.ContentType = "application/javascript; charset=utf-8";
            await ctx.Response.Send(Properties.Resources.app);
        });
        s.Routes.Static.Add(WatsonWebserver.HttpMethod.GET, "/app.css", async (ctx) => {
            ctx.Response.ContentType = "text/css; charset=utf-8";
            await ctx.Response.Send(Properties.Resources.app1);
        });
        s.Routes.Static.Add(WatsonWebserver.HttpMethod.GET, "/logo.png", async (ctx) => {
            ctx.Response.ContentType = "image/png";
            await ctx.Response.Send(Properties.Resources.logo);
        });
        s.Routes.Static.Add(WatsonWebserver.HttpMethod.GET, "/login", AuthorizeAsync);
        s.Start();

        Console.WriteLine("Press ENTER to exit");
        Console.ReadLine();
    }
    private static async Task AuthorizeAsync(HttpContext ctx)
    {
        var login = new Login(request);
        try
        {
            var l = await login.GetLogin();
            ctx.Response.StatusCode = 200;
            ctx.Response.ContentType = "application/json; charset=utf-8";
            await ctx.Response.Send(l.ToJson());
            return;
        }
        catch (Exception e)
        {
            Console.WriteLine(e.Message);
        }
    }
    static async Task DefaultRoute(HttpContext ctx)
    {
        ctx.Response.StatusCode = 200;
        ctx.Response.ContentType = "text/html; charset=utf-8";
        await ctx.Response.Send(Properties.Resources.index);
        return;
    }`

Thanks!

I’m using .Net 5.0

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
jchristncommented, Mar 23, 2021

Good to know! Operating systems are sensitive to cases where the listener prefix (ie 127.0.0.1) is compared to the value in the incoming request’s HOST header.

0reactions
vergoicincomcommented, Mar 23, 2021

@jchristn Thanks you for supported!

My problem solved when I changed 127.0.0.1 to localhost. It is the difference on my code and Test.Default

Thanks you very much!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to establish a route in Monterey.
The command appears to be accepted when entered on a terminal window, but the route/device can not be accessed via Safari.
Read more >
How to reload default Mac OSX routing table without ...
I think that step 1 is route flush (to remove all routes). And step 2 needs to reload all of the default routes....
Read more >
Apple MacOS appears to ignore default route assigned ...
All types of network traffic to non-local destinations fail (ping, web, ssh). And wireshark running on the MacBook shows the expected ARP and...
Read more >
n` into the Mac terminal, why doesn't it show a routing table ...
When I typed it into the terminal on a Mac, it returned the following: usage: route [-dnqtv] command [[modifiers] args].
Read more >
Getting "no route to host"in Mac OS X 10.5.8
If there is no default gateway, or the gateway has no information in its routing table to forward the packets, you'll see "no...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found