exam questions

Exam 70-486 All Questions

View all questions & answers for the 70-486 exam

Exam 70-486 topic 4 question 8 discussion

Actual exam question from Microsoft's 70-486
Question #: 8
Topic #: 4
[All 70-486 Questions]

You need to ensure that all the MVC controllers are secure.
Which code segment should you use as the body for the CreateController method in AdminVerifierFactory.cs?

  • A. Option A
  • B. Option B
  • C. Option C
  • D. Option D
Show Suggested Answer Hide Answer
Suggested Answer: C 🗳️
The MemberInfo.CustomAttributes property gets a collection that contains this member's custom attributes.
The Any() statement will either return null or a collection of matched custom attributes. If itmatches one or more, the controller is secure, otherwise an exception is thrown.
From scenario: The application contains a header that is visible on every page.
If the logged-on user is an administrator, then the header will contain links to administrative functions. This information is read from a cookie that is set on the server. The administrative links must not be present if an error condition is present.
Incorrect:
Not B: controller.GetType().Attributes will not return custom attributes.
References:
https://msdn.microsoft.com/en-us/library/system.reflection.memberinfo.customattributes(v=vs.110).aspx

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
elathir
4 years, 11 months ago
None is correct. C would by if there was == false not == null in the check. And as far as I know this examples, there is typo there and on the exam the check is correct.
upvoted 3 times
...
desona
5 years, 2 months ago
C is correct
upvoted 3 times
...
Ed64
5 years, 7 months ago
GetType().CustomAttributes does not exist (MemberInfo.GetCustomAttributes() does exist, but that is not returned by GetType()), and Any() returns a bool, not a collection (or null). C is bogus, B is the correct answer.
upvoted 4 times
alex_ozr
5 years, 7 months ago
Agree, B is correct
upvoted 2 times
...
drizet
5 years, 6 months ago
Disagree. Type is inherited from MemberInfo and it has CustomAttributes. B can't be correct because it uses Attributes. Attributes property has type TypeAttributes that is enum. But I agree that Any returns bool and can't return null.
upvoted 4 times
...
Dev666
5 years, 2 months ago
Is C https://msdn.microsoft.com/en-us/library/system.reflection.memberinfo.customattributes(v=vs.110).aspx
upvoted 3 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 ...