exam questions

Exam 70-486 All Questions

View all questions & answers for the 70-486 exam

Exam 70-486 topic 1 question 73 discussion

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

HOTSPOT -
You develop an ASP.NET MVC application. The application includes a feature that allows users to reset their passwords. The feature is enabled by a
ForgotPassword controller method and a corresponding Razor view.
You need to prevent Cross-Site Request Forgery (CSRF) attacks.
How should you complete the relevant code? To answer, select the appropriate code segment from each list in the answer area.
Hot Area:

Show Suggested Answer Hide Answer
Suggested Answer:
Example:
* At the top of the action that we createdto handle the posted form, the one with the [HttpPost] attribute added, we'll add another attribute named
[ValidateAntiForgeryToken]. This makes the start of our action now look like the following:
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult ChangeEmail(ChangeEmailModel model)
{
string username = WebSecurity.CurrentUserName;
*rest of function omitted*
* we must add the unique token to the form to change the user's email when we display it. Update the form in the ChangeEmail.aspx view under /Account/
ChangeForm:
<% using(Html.BeginForm()) { %>
<%: Html.AntiForgeryToken() %>
<%: Html.TextBoxFor(t=>t.NewEmail) %>
<input type="submit" value="Change Email" />
<% } %>

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
hungry_ape9000
5 years, 2 months ago
FINAL ANSWER: [ValidateAntiForgeryToken] Html.AntiForgeryToken()
upvoted 4 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 ...