c# - Unable to hit Web Api in .Net MVC -


hi starting mess webapi setup rest api angular app.

i added "web api 2 controller read/write actions"

i try test typing url in browser 404.

everything pretty out of box.

webapiconfig.cs looks like

    public static class webapiconfig {     public static void register(httpconfiguration config)     {         config.maphttpattributeroutes();          config.routes.maphttproute(             name: "defaultapi",             routetemplate: "api/{controller}/{id}",             defaults: new { id = routeparameter.optional }         );     } } 

routeconfig.cs is

    public class routeconfig {     public static void registerroutes(routecollection routes)     {         routes.ignoreroute("{resource}.axd/{*pathinfo}");          routes.maproute(             name: "default",             url: "{controller}/{action}/{id}",             defaults: new { controller = "home", action = "index", id = urlparameter.optional }         );     } } 

global.asax

        protected void application_start()     {         arearegistration.registerallareas();         filterconfig.registerglobalfilters(globalfilters.filters);         routeconfig.registerroutes(routetable.routes);         bundleconfig.registerbundles(bundletable.bundles);         globalconfiguration.configure(webapiconfig.register);          initializedatabase("data source=.;initial catalog=msproto;integrated security=true;multipleactiveresultsets=true;");     } 

is there have add web config? if add normal controller "mvc 5 controller read/write actions" hit breakpoints in requests.

make sure web api routes registered before mvc routes in global.asax.


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -