WebApiConfig and error 404

dashboard
Tags: #<Tag:0x00007f499ecd4440>

#1

Hello,
I have question about routing.
I have WebApiConfig :
public static void Register(HttpConfiguration config)
{
config.SuppressDefaultHostAuthentication();
config.Filters.Add(new HostAuthenticationFilter(OAuthDefaults.AuthenticationType));

        // Web API routes
        config.MapHttpAttributeRoutes();

       

        config.Routes.MapHttpRoute(
            name: "DefaultApi",
            routeTemplate: "{controller}/{action}/{id}",
            defaults: new { id = RouteParameter.Optional }
        );

And when i have “config.Routes.Maphttp…” i’m getting error when i trying to open other page than home dashboard if i comments “config.Routes…” i can open other pages but i need to have that route in my WebApiConfig.

It is possible to run dashboard with that route?


#2

so… no one knows ?


#3

I’m not totally sure I understand your question.

But I think mvc’s default route is conflicting with webapi’s.

You can’t have both mvc and web api like that. You need to prefix either your mvc urls or your web api ones.

This is why the default templates put /api on their default route.

(there isn’t anything about this issue that is specific to Hangfire).

You should put /api (or something else) in front of your web api route.

If you can’t do that, switch to attribute routing only in web api.

If you don’t want to do that, create a custom route constraint and add it to the default web api route. The custom constraint should prevent the route from matching if a matching controller doesn’t actually exist.


#4

The error 404 is due to Server Not Found error message and it is a report made by the server which is a response and you can troubleshoot it with the help of kaspersky antivirus error 1922