attributerouting

composite key resource REST service

心不动则不痛 提交于 2020-06-24 07:06:12
问题 I've come across a problem at work where I can't find information on the usual standard or practice for performing CRUD operations in a RESTful web service against a resource whose primary key is a composite of other resource ids. We are using MVC WebApi to create the controllers. For example, we have three tables: Product : PK=ProductId Part : PK=PartId ProductPartAssoc : PK=(ProductId, PartId) A product can have many parts and a part can be a component of many products. The association

RoutePrefix vs Route

♀尐吖头ヾ 提交于 2020-05-09 19:28:25
问题 I understand that RoutePrefix doesn't add a route to the routing table by itself. On your actions you need to have a Route attribute declared. I am having a hard time finding an authoritative blog/msdn page/ something that states why by defalut RoutePrefix doesn't add a route to the routing table. Does anyone have an authoritative post that does contain this to be the case, and if so will you let me know whom it is. Thank you very much. Edit To Clarify my question DOESN'T WORK [RoutePrefix(

RoutePrefix vs Route

梦想与她 提交于 2020-05-09 19:28:14
问题 I understand that RoutePrefix doesn't add a route to the routing table by itself. On your actions you need to have a Route attribute declared. I am having a hard time finding an authoritative blog/msdn page/ something that states why by defalut RoutePrefix doesn't add a route to the routing table. Does anyone have an authoritative post that does contain this to be the case, and if so will you let me know whom it is. Thank you very much. Edit To Clarify my question DOESN'T WORK [RoutePrefix(

Web Api Routing : Multiple controller types were found that match the URL

社会主义新天地 提交于 2020-04-30 16:35:49
问题 I'm getting,"Multiple controller types were found that match the URL", Error while performing postman operation for the below API Calls. Can someone help me figuring out the attribute mapping for the same. What I think is resolver considering the "respond" as the name of the Book. Thanks In Advance Code Snippet : public class BookApiController : ApiController { [HttpGet] [Route("api/v1/books/{bookName}")] public async Task<HttpResponseMessage> Get(string bookName){ /* Code Here */ } } public

Web Api Routing : Multiple controller types were found that match the URL

北城余情 提交于 2020-04-30 16:33:12
问题 I'm getting,"Multiple controller types were found that match the URL", Error while performing postman operation for the below API Calls. Can someone help me figuring out the attribute mapping for the same. What I think is resolver considering the "respond" as the name of the Book. Thanks In Advance Code Snippet : public class BookApiController : ApiController { [HttpGet] [Route("api/v1/books/{bookName}")] public async Task<HttpResponseMessage> Get(string bookName){ /* Code Here */ } } public

Route parameters and multiple controller types

安稳与你 提交于 2020-03-01 20:59:11
问题 I have a asp.net web api, using attributes for routing on the controllers. There are no route attriutes on the action level. The route for accessing a resource is: [Route("{id}"] public MyApiController: ApiController { public HttpResponseMessage Get(Guid id) { // ... } } My problem is that when I want to create a search controller, I'd like the URL to be [Route("search")] But this results in an error: Multiple controller types were found that match the URL . Is it possible to make sure the

Route parameters and multiple controller types

别说谁变了你拦得住时间么 提交于 2020-03-01 20:58:32
问题 I have a asp.net web api, using attributes for routing on the controllers. There are no route attriutes on the action level. The route for accessing a resource is: [Route("{id}"] public MyApiController: ApiController { public HttpResponseMessage Get(Guid id) { // ... } } My problem is that when I want to create a search controller, I'd like the URL to be [Route("search")] But this results in an error: Multiple controller types were found that match the URL . Is it possible to make sure the

Registering routes with ASP.Net 5's MVC 6 Attribute Routing

╄→尐↘猪︶ㄣ 提交于 2020-01-24 10:28:05
问题 When using Attribute Routing in ASP.Net MVC 5 you would call the command routes.MapMvcAttributeRoutes(); and then just add the Route() tag to the Controller/Actions you wanted to build routes to. I am now trying to do this in ASP.Net MVC 6 and have found many pages that show you how to do it, which is really no different than in MVC 5, but they don't show you where or how to register those routes. Does ASP.Net MVC 6 just due it for you automatically or is there an equivalent to routes

How to test AntiForgeryToken in MVC4 with backbone Single Page Application

落花浮王杯 提交于 2020-01-23 11:09:11
问题 I am having problems getting Microsoft's MVC's [ValidateAntiForgeryToken] to work with a Single Page Application (SPA) written using Marionette & Backbone. The problem seems to be that the MVC [ValidateAntiForgeryToken] method fails to see the token we send as part of the JSON. We thought it was because the token had to be in the Forms part of the reply but MrOggy85 says that isn't a problem (see his answer below). The code is in my api controllers, which use AttributeRouting, which we assume

Hide Area in URL using AttributeRouting

走远了吗. 提交于 2020-01-14 13:37:49
问题 We are using Areas to version an API written in ASP.NET MVC3 with AttributeRouting to define our routes. Right now we have a "v1" area that is our first version of API. When we got to v2, we will copy over v1 and make modifications. I want to use the same versioning for a website and I don't want the /v1 in the route. My question is, how do I hide the Area in my URL so I can call mywebsite.com/Users/1 instead of mywebsite.com/v1/Users/1 Here is what I have in my controller [RouteArea("/")]