• Register
0 votes
46 views

Problem :

I am using the Membership.create user function, then a below error is occurring:

“The required anti-forgery form field "__RequestVerificationToken" is not present”

How can I resolve above error?

7 5 2
3,870 points

Please log in or register to answer this question.

1 Answer

0 votes

Solution :

If you have a [ValidateAntiForgeryToken] attribute before the action. Then you also should add a @Html.AntiForgeryToken() in the form.

OR

In my case, I had below code in my web.config:

<httpCookies requireSSL="true" />

But my project was set to not use the SSL. So commenting out that line or setting up a project to always use the SSL solved it.

OR

Please make sure that in your controller that you have the http attribute like:

[HttpPost]

Also add a attribute in a controller:

[ValidateAntiForgeryToken]

In your form on the view you have to write as below:

@Html.AntiForgeryToken();

I had the Html.AntiForgeryToken(); without a @ sign while it was in the code block, it didn't give the error in Razor but did give at runtime. So make sure you look at the @ sign of @Html.Ant.. if it is missing there or not

 OR

If anyone is experiencing a error for the same reason why I experience it, then here's my solution:

If you had a Html.AntiForgeryToken();

Then change it to @Html.AntiForgeryToken()

9 7 4
38,600 points

Related questions

1 vote
1 answer 43 views
43 views
Problem : While binding the dropdown in MVC, I often face following error: There is no ViewData item of type 'IEnumerable<SelectListItem>' that has the key country. Please find below my View for your reference : @Html.DropDownList("country", (IEnumerable<SelectListItem>)ViewBag ... .countryid.ToString() }); } ViewBag.mycountrydrop = myitem8; return View(); I do not know how to resolve above error.
asked Dec 28, 2019 alecxe 7.5k points
0 votes
1 answer 28 views
28 views
Problem: Currently I have the table called Student in the database with some of the values and I am trying to display the values in the webgrid with the help of entityframework. I have done exactly the same kind of work before many times using the Ado.net, but ... I assign the VAR value to List also is this my correct approach? Kindly guide me in fixing my problem related to Entity Framework.
asked Jul 3, 2020 Raphael Pacheco 4.9k points
0 votes
1 answer 547 views
547 views
Problem : Facing following ASP.Net error an asynchronous module or handler completed while an asynchronous operation was still pending.
asked Nov 14, 2019 peterlaw 6.9k points
0 votes
2 answers 292 views
292 views
Problem : Currently I am migrating from the Identity 1.0.0 to Identity 2.0.1. But the migrations code generated is nothing about the new IdentityUser. And It does not even add the new columns. So I tried to make the new project and also I ... current context At below line IdentityResult result = await UserManager.CreateAsync(user, model.Password); Any clue about the solution on my above problem?
asked Dec 25, 2019 alecxe 7.5k points
0 votes
1 answer 55 views
55 views
Problem : I am having my radcombo machines on aspx page and whenever I try to select any option from them then it gives me following `Server Error in '/' Application. Exception Details: System.InvalidOperationException: Operation is not valid due to the current state of the object. My Version Information: Microsoft .NET Framework Version: 2.0.50727.3634 ASP.NET Version: 2.0.50727.3634
asked Dec 2, 2019 alecxe 7.5k points
0 votes
1 answer 16 views
16 views
How can you find the mime type of a file based on the file signature, not the extension in .Net? I want a simple way to get a mime type where the file extension is incorrect or not given, something similar?
asked Aug 29, 2020 Aliza313 720 points
0 votes
1 answer 18 views
18 views
Problem: I am trying to enable CORS on one of the very specific actions in my Asp.net Web Api. Please find below my code and tell me if I am missing anything: [Route("api/mycontroller/myaction")] [HttpPost] [EnableCors("https://example.com", "*", "post")] public ... http method 'OPTIONS'." I also tried to remove the [HttpPost] annotation but to no avail. Have I made any mistake in my above code?
asked Aug 19, 2020 Raphael Pacheco 4.9k points
1 vote
1 answer 12 views
12 views
Problem: I am having fundamental knowledge on C#. Currently I am unable to connect to the HTTPS server with the use of WebRequest as I am facing below error message: "The request was aborted: Could not create SSL/TLS secure channel." I understand that my ... my server never really validates a certificate and it fails with a above error. Kindly guide me in fixing above certificate related error.
asked Jun 30, 2020 Raphael Pacheco 4.9k points
0 votes
1 answer 58 views
58 views
Problem : I have my newly created website. First time I was able to succesfully login. The default address: www.abc.com I typed above address on browser and it redirected me to my login page: www.abc.com/pages/landingpage.aspx When I entered my login credential and tried to log ... open my site number of tabs and the browsers but as soon as I am logged in to my site, I am getting the above error.
asked Jan 31, 2020 jwilliam 3.9k points
0 votes
1 answer 58 views
58 views
Problem : I am very new to ASP.Net. I have created my first ASP.Net application which impersonates the user in order to create the AD group, and after that it launches the powershell process as the user saperately. But because of some reason the group ... I would rather not compromise with the security policy with the server ideally, and this application will be used by around 100+ users.
asked Dec 5, 2019 alecxe 7.5k points