1

I'm trying to get the parameters of specific attribute routed URL on ActionFilterAttribute. For instance I have an action like below:

[Route("/v1/test/{userId}/{udid}")]
public object GetNewObject(int userId, string udid) 

And in action filter attribute the absolute url is coming something like "http://test.example.com/v1/test/1/123-asda-231-asd". However I want to parse these parameters as userId=1 and udid=... within a collection.

Is it possible?

4

2 に答える 2

1

[Route("...")] は MVC 5 でのみ可能です。

[RoutePrefix("api/users")]
public class UsersController : ApiController
{
    // GET api/users
    [Route("")]
    public IEnumerable<User> Get() { ... }

    // GET api/user/5
    [Route("{id:int}")]
    public Book Get(int id) { ... }

    // POST api/users
    [Route("")]
    public HttpResponseMessage Post(User book) { ... }
}

各ユーザーがあなたのプロパティを含む場所

public class User
{
     int UserId{get;set;}
     string Udid{get; set;} 
}
于 2013-10-22T21:36:54.443 に答える