Asp.Net Core I'm getting 404 error problem

2020-05-07 07:31发布

问题:

I'm getting a 404 error but the problem is solved when I refresh the page.

This url is being called by a service. In this case it always gets error. If I refresh the page the problem is getting better. The page opens.

Where is the problem? Can you help me?

My Callback Parameter:

CallbackUrl = $"{httpContext.Request.Scheme}://{httpContext.Request.Host}{httpContext.Request.PathBase}/company/payment/callbackpayments/?data=" + model.Transaction.Id.ToString()

IActionResult:

[HttpGet]
[AllowAnonymous]
public IActionResult CallbackPayments(string data)
{
   return RedirectToAction("Index","Dashboard",new { area="Company"});
}

回答1:

try changing

[HttpGet]

to this:

[HttpGet("company/payment/callbackpayments/?data={data}")]

or make sure your controller has /company/payment in a route attribute [Route("company/payment")]