2

It's just a WHY question as it maybe a miss-concept :(

The following is the default Web API configuration in ASP.net Web Api Project

public static class WebApiConfig
{
    public static void Register(HttpConfiguration config)
    {
        config.Routes.MapHttpRoute(
            name: "DefaultApi",
            routeTemplate: "api/{controller}/{id}",
            defaults: new { id = RouteParameter.Optional }
        );
    }
}

I tried changing

api / {controller} / {id}

to

# / {controller} / {id}

Not working, the ambitious part is that it's being ignored ( NO 404 ) as if I'm routing to my Home page, however other consumptions worked perfectly like

- / {controller} / {id}

Seems to be an encoding issue miss-concept part, any help ?

Ahmed Ghoneim
  • 6,834
  • 9
  • 49
  • 79

2 Answers2

1

The "#" sign is interpreted by browsers as a bookmark and is typically not sent to the server. I recommend running a tool such as Fiddler or your browser's development tools (such as the F12 tools in IE) and see what request is actually being sent to the server.

Eilon
  • 25,582
  • 3
  • 84
  • 102
1

The # is wrong selection. This part is relevant only on a client and will allow to scroll to element with the name equal to part after the hash

Check this answer: https://stackoverflow.com/a/967659/1679310

Extract:

... I am afraid not, since the hash (the string including the #) never gets passed to the server, it is solely a behavioural property of the browser. The $_SERVER['REQUEST_URI'] variable will contain the rest however.

So, while part after (including) the # is never send to server, you cannot use it as a part of your routing

Community
  • 1
  • 1
Radim Köhler
  • 122,561
  • 47
  • 239
  • 335