OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

C# ajax post request 404 not found

  • Thread starter Thread starter Ben Bodie
  • Start date Start date
B

Ben Bodie

Guest
I have an ajax query running from a page located in a folder Project/Pages/IT/NewEmailSetup

I want it to call a post request to a controller thats located in Project/Controllers/TestEmailSenderController

I have tried all manner of things but no matter what I do It just returns a 404 error.

My most recent test looks like the below:

Ajax Query:

Code:
$.ajax({
type: 'post',
url: '/Controllers/TestEmailSender/Send',
contentType: 'application/json',
data: { "EmailInfo": inner }
});

Then within my controller is the following:

Code:
[Route("Controllers/[controller]")]
public class TestEmailSenderController : Controller
{
 public IActionResult Index()
 {
     return View();
 }
 [HttpPost]
 [Route("Send")]
 public ActionResult Send(string EmailInfo)
 {
 //Action code
 }
}

Any help would be much appreciated I am very new to ajax / websites in general.

Image


<p>I have an ajax query running from a page located in a folder Project/Pages/IT/NewEmailSetup</p>
<p>I want it to call a post request to a controller thats located in Project/Controllers/TestEmailSenderController</p>
<p>I have tried all manner of things but no matter what I do It just returns a 404 error.</p>
<p>My most recent test looks like the below:</p>
<p>Ajax Query:</p>
<pre><code>$.ajax({
type: 'post',
url: '/Controllers/TestEmailSender/Send',
contentType: 'application/json',
data: { "EmailInfo": inner }
});
</code></pre>
<p>Then within my controller is the following:</p>
<pre><code>[Route("Controllers/[controller]")]
public class TestEmailSenderController : Controller
{
public IActionResult Index()
{
return View();
}
[HttpPost]
[Route("Send")]
public ActionResult Send(string EmailInfo)
{
//Action code
}
}
</code></pre>
<p>Any help would be much appreciated I am very new to ajax / websites in general.</p>
<p><img src="https://i.gyazo.com/3ad04932943920bc71129cde41bdf839.png" alt=""Image"" /></p>
 
Top