asp.net mvc - What would cause attribute routing to not work when adding it to an existing MVC 5 web app? -



asp.net mvc - What would cause attribute routing to not work when adding it to an existing MVC 5 web app? -

i added web api nuget , startup webapiconfig code calls maphttpattributeroutes via global.asax, none of attribute routes working.

protected void application_start() { sqlservertypes.utilities.loadnativeassemblies(server.mappath("~/bin")); mvchandler.disablemvcresponseheader = true; arearegistration.registerallareas(); globalconfiguration.configure(webapiconfig.register); filterconfig.registerglobalfilters(globalfilters.filters); routeconfig.registerroutes(routetable.routes); }

here packages installed.

<packages> <package id="entityframework" version="6.1.1" targetframework="net451" /> <package id="microsoft.aspnet.identity.core" version="2.0.1" targetframework="net451" /> <package id="microsoft.aspnet.identity.entityframework" version="2.0.1" targetframework="net451" /> <package id="microsoft.aspnet.identity.owin" version="2.0.1" targetframework="net451" /> <package id="microsoft.aspnet.mvc" version="5.1.2" targetframework="net451" /> <package id="microsoft.aspnet.razor" version="3.1.2" targetframework="net451" /> <package id="microsoft.aspnet.webapi" version="5.1.2" targetframework="net451" /> <package id="microsoft.aspnet.webapi.client" version="5.1.2" targetframework="net451" /> <package id="microsoft.aspnet.webapi.core" version="5.1.2" targetframework="net451" /> <package id="microsoft.aspnet.webapi.owin" version="5.1.2" targetframework="net451" /> <package id="microsoft.aspnet.webapi.webhost" version="5.1.2" targetframework="net451" /> <package id="microsoft.aspnet.webpages" version="3.1.2" targetframework="net451" /> <package id="microsoft.aspnet.webpages.data" version="3.1.2" targetframework="net451" /> <package id="microsoft.aspnet.webpages.webdata" version="3.1.2" targetframework="net451" /> <package id="microsoft.data.edm" version="5.6.1" targetframework="net451" /> <package id="microsoft.data.odata" version="5.6.1" targetframework="net451" /> <package id="microsoft.data.services.client" version="5.6.1" targetframework="net451" /> <package id="microsoft.owin" version="2.1.0" targetframework="net451" /> <package id="microsoft.owin.host.systemweb" version="2.1.0" targetframework="net451" /> <package id="microsoft.owin.security" version="2.1.0" targetframework="net451" /> <package id="microsoft.owin.security.cookies" version="2.1.0" targetframework="net451" /> <package id="microsoft.owin.security.oauth" version="2.1.0" targetframework="net451" /> <package id="microsoft.sqlserver.types" version="11.0.1" targetframework="net451" /> <package id="microsoft.web.infrastructure" version="1.0.0.0" targetframework="net45" /> <package id="microsoft.windowsazure.configurationmanager" version="2.0.3" targetframework="net451" /> <package id="newtonsoft.json" version="6.0.3" targetframework="net451" /> <package id="owin" version="1.0" targetframework="net451" /> <package id="restsharp" version="104.4.0" targetframework="net451" /> <package id="sharpziplib" version="0.86.0" targetframework="net451" /> <package id="system.spatial" version="5.6.1" targetframework="net451" /> <package id="windowsazure.storage" version="4.0.1" targetframework="net451" /> </packages>

controller code

[authorize(roles = "admin")] [routeprefix("admin/api/v/{vid}/photos")] public class photoscontroller : apicontroller { [allowanonymous] [route("test", name="test")] [httpget] public ihttpactionresult test(string vid) { homecoming ok(); } }

i figured out going on, had 2 api controllers same name. looks if web api attribute routing not differentiate actions , controllers namespace constraint mvc does. prepended admin command class name , seems work now.

asp.net-mvc asp.net-web-api2 asp.net-web-api-routing

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -