can I return object in razor pages?

mc 5,061 Reputation points
2025-01-18T02:34:55.8966667+00:00

can I return object in razor pages?

public async Task<object>OnPostDeleteAsync()
{
return MySuccessMessage();
}
ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,738 questions
{count} votes

1 answer

Sort by: Most helpful
  1. AgaveJoe 29,281 Reputation points
    2025-01-18T12:13:25.99+00:00

    can I return object in razor pages?

    I'm guessing you have a client application, maybe JavaScript, that calls OnPostDeleteAsync(). The problem you are trying to solve, is making an AJAX call to delete a resource. But, you need the results of the delete operation to update the document loaded in the browser. See the following tutorial if you are trying make AJAX calls to Razor Page handlers and process the results.

    https://www.mikesdotnetting.com/article/318/working-with-json-in-razor-pages

    If the above does not answer your question, then explain what you are trying to do.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.