Upload File Controller not triggered by RadzenUpload Url

In a page, I add the code
<RadzenUpload Url="upload/single" Style="margin-bottom: 20px;"
Progress="@((args) => OnProgress(args, "Single file upload"))" />

Then I created a UploadController.cs. But the controller is never triggered. But the website still shows 100% progress after I click the button. No matter adding [Route("[controller]")] and [ApiController]. or not, the controller is never triggered. Can anyone help?

[Route("[controller]")]
[ApiController]
[DisableRequestSizeLimit]
public class UploadController : Controller
{
    private readonly IWebHostEnvironment _environment;
    public UploadController(IWebHostEnvironment environment)
    {
        _environment = environment;
    }

    [HttpPost("upload/single")]
    public IActionResult Single(IFormFile file)
    {
        try
        {
            UploadFile(file);
            return StatusCode(200);
        } catch (Exception ex)
        {
            return StatusCode(500, ex.Message);
        }

    }

    public async Task UploadFile(IFormFile file)
    {
        if (file!=null && file.Length > 0)
        {
            var imagePath = @"\Upload";
            var uploadPath = _environment.WebRootPath + imagePath;
            if (!Directory.Exists(uploadPath))
            {
                Directory.CreateDirectory(uploadPath);
            }

            var fullPath = Path.Combine(uploadPath, file.FileName);
            using (FileStream fileStream = new FileStream(fullPath, FileMode.Create,FileAccess.Write))
            {
                await file.CopyToAsync(fileStream);
            }
        }
    }
}

}

Hi @t.leung,

Controllers may not be enabled in your application. You should make sure you have the following line in your Startup.cs:

endpoints.MapControllers();

or

endpoints.MapControllerRoute(
   name: "default",
   pattern: "{controller=Home}/{action=Index}/{id?}");

Hi, thanks for your reply.
I haven't added endpoint.MapControllers() in the startup. But I modified the controller and finally solved the problem. The key point is I use "ControllerBase" instead of "Controller".
[DisableRequestSizeLimit]
public partial class UploadController : ControllerBase
{
private readonly IWebHostEnvironment _env;

    public UploadController(IWebHostEnvironment env)
    {
        _env = env;
    }

    [HttpPost("upload/single")]
    public IActionResult Single(IFormFile file)
    {
        try
        {
            UploadFile(file);
            return StatusCode(200);
        }
        catch (Exception ex)
        {
            return StatusCode(500, ex.Message);
        }
    }

    //[HttpPost("upload/multiple")]
    //public IActionResult Multiple(IFormFile[] files)
    //{
    //    try
    //    {
    //        UploadFile(file);
    //        return StatusCode(200);
    //    }
    //    catch (Exception ex)
    //    {
    //        return StatusCode(500, ex.Message);
    //    }
    //}

    [HttpPost("upload/{id}")]
    public IActionResult Post(IFormFile[] files, int id)
    {
        try
        {
            // Put your code here
            return StatusCode(200);
        }
        catch (Exception ex)
        {
            return StatusCode(500, ex.Message);
        }
    }

    public async Task UploadFile(IFormFile file)
    {
        if (file !=null && file.Length > 0)
        {
            var imagePath = @"\Upload";
            var uploadPath = _env.WebRootPath + imagePath;
            if (!Directory.Exists(uploadPath))
            {
                Directory.CreateDirectory(uploadPath);
            }
            var fullPath = Path.Combine(uploadPath, file.FileName);
            using(FileStream fileStream = new FileStream(fullPath, FileMode.Create, FileAccess.Write))
            {
                await file.CopyToAsync(fileStream);
            }
        }
    }
}

}