'Razor Page Trouble calling Post Method

I have a .cshtml file and it's .cs file. I am using Razor pages. I am using Dropzone for uploading a file. The action in the form doesn't hit the method in the .cs page. I cannot figure out why the code in the .cs file is not hit. I used break points and it never appears to ever get to c# code. Can anyone see what I am doing wrong?

-----------
@page
@model SipiARPortal.Pages.SystemAdmin.AdminUsersModel
@inject IVendor _vendor
@{
ViewData["Title"] = "Admin File Upload";
ViewData["Header"] = new PageHeader()
{
    Title = "ADMIN FILE UPLOAD",
    SubTitle = "Upload Files here",
    Breadcrumbs = new List<Breadcrumb>() {
        new Breadcrumb() { Name = "Admin File Uplaod", URL = "/systemadmin/adminfileupload" }
    }
  };
 }
<link href="~/css/dropzone.css" rel="stylesheet" />
<div class="card shadow-sm mb-5">
<div class="card-body">
    <div class="row">
        <form action="/systemadmin/adminfileupload" method="post"
             class="dropzone" enctype="multipart/form-data"
              id="my-dropzone">
        </form>
    </div>
    <div class="row mg-t-5">
        <div id="verification" class="col-12"></div>
    </div>
    </div>
    </div>
   @section Scripts {
   <script src="~/lib/dropzone/dropzone.js"></script>
<script type="text/javascript">
    var gridObj = null;
    Dropzone.options.myDropzone = {
        createImageThumbnails: false,
        acceptedFiles:'',
        allowedExtensions: '.pdf,.zip',
        dictDefaultMessage: 'Drop results file here for verification',
        init: function () {
            this.on("success", function (file, data) {
                magalert.ajaxMessage(data);
                if (data.success) {
                    if (gridObj !== null) {
                        $("#Grid").ejGrid("destroy");
                    }
                    gridObj = $("#verification").ejGrid({
                        dataSource: data.data,
                        allowPaging: true,
                        allowSorting: true,
                        isResponsive: true,
                        allowFiltering: true,
                        enableHeaderHover: true,
                        filterSettings: { filterType: "excel" },
                        columns: [
                            { field: "filename", headerText: "FileName", width: 275 },
                           
                        ]
                    });
                    var target = $('#verification');
                    if (target.length) {
                        $('html,body').animate({
                            scrollTop: target.offset().top
                        }, 1000);
                    }
                }
                e
            });
        }
    };
   
</script>
}

---------
namespace SipiARPortal.Pages.SystemAdmin
{
[Authorize(Roles = "SystemAdmin,SipiAdmin")]
public class AdminFileUploadsModel : PageModel
{
    private readonly ILogger<AdminUsersModel> _logger;
    private readonly UserManager<ApplicationUser> _userManager;
    public readonly IAzureBlob _blob;
    private readonly ApplicationDbContext _db;
    private readonly ConfigurationDbContext _cdb;
   

    public async Task OnPostAsync(IFormFile UploadFiles)
    {
        await _blob.SaveFileStream(UploadFiles.OpenReadStream(), "pending", UploadFiles.FileName);
        
    }
    [HttpPost]
    public async Task<IActionResult> ResultsUpload(IFormFile UploadFiles)
    {

        ServiceResult<List<ResultIssue>> retVal = new ServiceResult<List<ResultIssue>>() { Data = new List<ResultIssue>(), Success = true };
        try 
        {
            await _blob.SaveFileStream(UploadFiles.OpenReadStream(), "pending", UploadFiles.FileName);
            //var blobStream = await _blob.GetFileStream(blob, sigFileName);
        }
        catch (Exception ex)
        {
            _logger.LogError(ex, "Results Upload");
            retVal.Message = "Error parsing results file - did you select the correct format?";
            retVal.Success = false;
        }
        return new JsonResult(retVal);
    }

}


}


Solution 1:[1]

  1. The request url should be /systemadmin/adminfileuploads, you miss an s.

  2. Anti-forgery token validation is enabled by default in Razor Pages. You need manually add it by using @Html.AntiForgeryToken() in the form.

    <form action="/systemadmin/adminfileuploads" method="post"
         class="dropzone" enctype="multipart/form-data"
         id="my-dropzone">
         @Html.AntiForgeryToken()
    </form>
    

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Rena