NEW AI Search is now live Try it →
Navigation
Clyzo || Testimonials
New Test Blog After Marge The Code
Sourcing

New Test Blog After Marge The Code

24-06-2026

Yes, there are a few mismatching pieces between your JavaScript fetch request and your C# Controller method that are keeping them from connecting.

Here are the main issues causing the breakdown, ranked from most critical to least:

1.

The Anti-Forgery Token Header Mismatch (Most Critical)

In your JavaScript, you are passing the token using the header key 'RequestVerificationToken':

JavaScript


headers: { ..., 'RequestVerificationToken': getAntiForgeryToken() }

However, standard ASP.NET MVC’s [ValidateAntiForgeryToken] attribute looks for a header named __RequestVerificationToken (with two underscores), or it expects it inside the request body.

Because the names don't match, your server is likely rejecting the request with a 403 Forbidden or 500 error before it even hits your controller action.

2.

Missing Parameters in the Controller

Your C# controller is expecting a parameter called prmBlogId from the URL route, but it isn't expecting the status variable you are sending in the body.

  1. Your fetch body sends: 'status=' + status
  2. Your controller signature only accepts: int prmBlogId

If you actually want to use that status boolean inside your controller, your C# method needs to accept it.

How to Fix It

Here is the corrected code for both sides to make sure they talk to each other flawlessly.

Updated JavaScript

JavaScript


document.getElementById('blogTable').addEventListener('click', function (e) {
var btn = e.target.closest('.btn-toggle-status');
if (!btn) return;
var id = btn.getAttribute('data-id');
var status = btn.getAttribute('data-status') === '1';
// Ensure you are fetching the token correctly
var token = typeof getAntiForgeryToken === 'function' ? getAntiForgeryToken() : $('input[name="__RequestVerificationToken"]').val();

fetch('/Blog/ToggleStatus/' + id, {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
// FIX: ASP.NET looks for '__RequestVerificationToken' by default
'__RequestVerificationToken': token
},
// Sending status in the body
body: 'prmStatus=' + status
})
.then(function (r) { return r.json(); })
.then(function (json) {
if (json.success) window.blogTableManager.reload();
else alert(json.message);
});
});


Test blog for QC

Test blog for QC

24-06-2026
New Test Blog After Marge The Code

New Test Blog After Marge The Code

24-06-2026
Excipients for Injectable Formulations in India: What Every Pharma Manufacturer Needs to Know

Excipients for Injectable Formulations in India: W... ... Excipients for Injectable Formulations in India: What Every Pharma Manufacturer Needs to Know Read more

23-06-2026
Test blog title for insert this record.

Test blog title for insert this record.

20-06-2026
The Future l Tratal Transformation_2

The Future l Tratal Transformation_2

17-06-2026
The Future l Tratal Transformation_3

The Future l Tratal Transformation_3

17-06-2026
The Future of Digital Transformation in Digital Transformation

The Future of Digital Transformation in Digital Tr... ... The Future of Digital Transformation in Digital Transformation Read more

12-06-2026
The Future of Digital Transformation in Digital Transformation

The Future of Digital Transformation in Digital Tr... ... The Future of Digital Transformation in Digital Transformation Read more

12-06-2026
The Future of Digital Transformation Digital Transformation

The Future of Digital Transformation Digital Trans... ... The Future of Digital Transformation Digital Transformation Read more

12-06-2026
The Future of Digital Transformation Digital Transformation

The Future of Digital Transformation Digital Trans... ... The Future of Digital Transformation Digital Transformation Read more

12-06-2026
The Future of Digital Transformation Digital Transformation

The Future of Digital Transformation Digital Trans... ... The Future of Digital Transformation Digital Transformation Read more

12-06-2026
The Future of Digital Transformation Digital Transformation

The Future of Digital Transformation Digital Trans... ... The Future of Digital Transformation Digital Transformation Read more

12-06-2026
The Future l Tratal Transformation

The Future l Tratal Transformation

12-06-2026
The Future of Digital Transformation in Pharma Digital Transformation

The Future of Digital Transformation in Pharma Dig... ... The Future of Digital Transformation in Pharma Digital Transformation Read more

12-06-2026