exam questions

Exam 70-487 All Questions

View all questions & answers for the 70-487 exam

Exam 70-487 topic 1 question 37 discussion

Actual exam question from Microsoft's 70-487
Question #: 37
Topic #: 1
[All 70-487 Questions]

DRAG DROP -
You are developing an ASP.NET Web API for a home inventory management system.
You need to limit access to users with IP addresses based only in the United States.
You have the following code:

Which code segments should you include in Target 1 and Target 2 to complete the code? (To answer, drag the appropriate code segments to the correct targets in the answer area. Each code segment may be used once, more than once, or nor at all. You may need to drag the split bar between panes or scroll to view content.)
Select and Place:

Show Suggested Answer Hide Answer
Suggested Answer:

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
kamchu
Highly Voted 5 years, 3 months ago
The correct answer would be Target 1: AuthorizationFilterAttribute Target 2: HttpActionContext
upvoted 19 times
Moca3
5 years, 1 month ago
I'm Agree
upvoted 4 times
...
...
abalone
Highly Voted 5 years, 5 months ago
Answer is Correct. 1. AuthorizeAttribute 2. HttpActionContext Source: https://gist.github.com/rdingwall/2028849
upvoted 13 times
...
Ptu12125
Most Recent 4 years, 3 months ago
For Web API :AuthorizationFilterAttribute Class has a method OnAuthorization(HttpActionContext)" - Calls when a process requests authorization. "https://docs.microsoft.com/en-us/previous-versions/aspnet/hh834134(v=vs.118)
upvoted 1 times
...
gokhan
4 years, 4 months ago
Target 1: AuthorizationFilterAttribute Target 2: HttpActionContext
upvoted 5 times
...
piedro
4 years, 5 months ago
Just scroll to the bottom of the page... https://docs.microsoft.com/en-us/aspnet/web-api/overview/security/authentication-and-authorization-in-aspnet-web-api IAuthorizationFilter <- AuthorizationFilterAtrbute <- AuthorizeAtribute It looks like you can get the job done with both of them BUT... 1. It is nowhere mentionen that the user is logged in.... it can also be an anonymous user 2. You dont need the current user or its roles...you just need the UserHostAddress from Request 3. If you read about the AuthorizationAttribute you will find this: "Authorization is denied in the following cases: The request is not associated with any user || The user is not authenticated." Source: https://docs.microsoft.com/en-us/previous-versions/aspnet/hh834985(v=vs.108) I think the right answear is AuthorizationFilterAtribute and HttpActionContext
upvoted 4 times
...
Jobair
4 years, 7 months ago
For WebApi https://docs.microsoft.com/en-us/previous-versions/aspnet/mt134843(v=vs.118)
upvoted 1 times
...
zimzimzimma
4 years, 7 months ago
I still think it is 1. AuthorizeAttribute 2. AuthorizationContext https://docs.microsoft.com/en-us/aspnet/web-api/overview/security/authentication-and-authorization-in-aspnet-web-api All other links I am seeing are based on content from 2013... 7 years ago. I think Microsoft has moved on now and things have changed.
upvoted 1 times
zimzimzimma
4 years, 7 months ago
HttpActionContext is correct after all. Moderators, please remove this and above comment.
upvoted 1 times
...
...
tiger25
5 years, 2 months ago
That's the most weird question, both AuthorizeAttribute and AuthorizeFilterAttribute are correct. //https://www.oreilly.com/library/view/aspnet-web-api/9781785882210/ch01s07.html
upvoted 1 times
Natali
4 years, 11 months ago
AuthorizeAttribute Extend this class to perform authorization logic based on the current user and the user’s roles. ■ AuthorizationFilterAttribute Extend this class to perform synchronous authorization logic that is not necessarily based on the current user or role I think it should be AuthorizeAttribute because auth depends on user
upvoted 2 times
...
...
TinaZh
5 years, 2 months ago
I think correct answer is AuthorizationFilterAttribute HttpActionContext From docs: "AuthorizeAttribute. Extend this class to perform authorization logic based on the current user and the user's roles. AuthorizationFilterAttribute. Extend this class to perform synchronous authorization logic that is not necessarily based on the current user or role." USAIp does not based on current role. https://docs.microsoft.com/en-us/aspnet/web-api/overview/security/authentication-and-authorization-in-aspnet-web-api#custom-authorization-filters And example https://docs.microsoft.com/en-us/odata/webapi/basic-auth
upvoted 6 times
...
akh
5 years, 4 months ago
Target 1: AuthorizationFilterAttribute Target 2: HttpActionContext https://weblog.west-wind.com/posts/2013/apr/18/a-webapi-basic-authentication-authorization-filter
upvoted 10 times
...
dosper
5 years, 5 months ago
AuthorizeAttribute AuthorizationContext
upvoted 1 times
...
koshiishi
5 years, 5 months ago
I Think Target2 is AuthorizationContext https://docs.microsoft.com/en-us/dotnet/api/system.web.mvc.authorizeattribute.onauthorization?view=aspnet-mvc-5.2#System_Web_Mvc_AuthorizeAttribute_OnAuthorization_System_Web_Mvc_AuthorizationContext_
upvoted 3 times
MJKWandile
5 years, 5 months ago
WebApi -> HttpActionContext MVC -> AuthorizationContext
upvoted 19 times
tanujgyan
4 years, 10 months ago
This comment clarifies it
upvoted 2 times
...
zimzimzimma
4 years, 7 months ago
Not anymore: https://docs.microsoft.com/en-us/aspnet/web-api/overview/security/authentication-and-authorization-in-aspnet-web-api
upvoted 1 times
zimzimzimma
4 years, 7 months ago
Apologies, HttpActionContext is correct after all. Moderators, please remove this and above comment.
upvoted 1 times
...
...
...
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago