Issue with ASP.NET Core Upload Asynchronous Upload - Save-Url doesnt see handler on code [Code Behind] ( iam using Razor page)

1 Answer 63 Views
Upload
Asif
Top achievements
Rank 1
Asif asked on 10 Jan 2024, 05:35 AM

Razor code-behind method: I made the razor method as simple as possible, just to see if we could get in there / or hit onpostUploadFile
        public async Task<ActionResult> OnPostUploadFile(IEnumerable<IFormFile> files, string metaData)
        {
            AllowedExtensions = new string[] { "fpd", "pdf" };

            return Page();
        }

Razor page :

@addTagHelper *, Kendo.Mvc
<div>
    <div class="demo-section">
        <kendo-upload name="files">
            <async auto-upload="true" save-url="@Url.Action("Upload","UploadFile")" chunk-size="11000" />
            <validation max-file-size="20000000" />
        </kendo-upload>
    </div>
</div>

The issue is i am not able to hit the hander from the razor page when i pass the url to <async save-url="">, Despite many efforts, the handler specified in the save-url attribute doesn't seem to be hit and returns 404.

Not Working: 

1. save-url: "/Upload/UploadFile",

2. save-url="./Upload?handler=UploadFile"

I also found Forum where it discussed the same problem but that didn't help us :https://www.telerik.com/forums/upload-using-tag-helpers

 

1 Answer, 1 is accepted

Sort by
0
Mihaela
Telerik team
answered on 17 Jan 2024, 12:04 PM

Hello Asif,

Since we discussed the issue in a support ticket, I will post the same answer here in case someone else has the same question:

When using Razor Pages, the correct way to specify the Upload Save Action is to use the @Url.Page() method, as per the example below:

<kendo-upload name="files">
    <async auto-upload="true" save-url="@Url.Page("Index","Upload")"  chunk-size="11000" />
    <validation max-file-size="20000000" />
</kendo-upload>

//Page Model
public async Task<ActionResult> OnPostUpload(IEnumerable<IFormFile> files, string metaData)
{
  ...
}

Alternatively, you can set the "save-url" as follows:

<kendo-upload name="files">
    <async auto-upload="true" save-url="/Index?handler=Upload"  chunk-size="11000" />
    <validation max-file-size="20000000" />
</kendo-upload>

Regards,
Mihaela
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages. If you're new to the Telerik family, be sure to check out our getting started resources, as well as the only REPL playground for creating, saving, running, and sharing server-side code.
Tags
Upload
Asked by
Asif
Top achievements
Rank 1
Answers by
Mihaela
Telerik team
Share this question
or