3
I own a Controller
in my project Asp.net (Web Service) I need to do a token check for each method request. One solution I found is to create a static method and place a call at each start of each method. I could put only once in the builder of mine Controller
but here’s the problem: not all methods need this verification.
Then I would like to know how to implement an Annotations with my verification implementation and use Annotations to validate these requests. If the request is invalid, the request is sent to a 404 page.
I would like a horizon of how to do this, something like this pseudo-code below:
@VerificationToken
public List<Produto> getAllProducts(){
// implementação
}
I think what he wants is not really an authentication. It’s kind of a custom token validation. Derive the
[Authorize]
would work well if his project wasn’t a Web Service.– Leonel Sanches da Silva
I’m not sure about the type of project, because the question mentions a redirect to a 404 page, which makes little sense to a web-service.
– Miguel Angelo
It would only be valid if on the return of the web-service it was a call to a page, and on the return when invalid came the request to the 404
– Tafarel Chicotti
Michelangelo I mentioned a 404 return but not necessarily 404, it may be a custom json return informing the client that authentication via token failed.
– Tuyoshi Vinicius