AlvinfromDiaspar
AlvinfromDiaspar

Reputation: 6834

Asp.net Core - How to InvokeAsync for a ViewComponent from javascript?

I have a simple ViewComponent (i.e. partialview) which i can do an InvokeAsyn() to render a small snippet of HTML by placing the invoke code within my CSHTML.

Question

How can I call a ViewComponent InvokeAsync (or any method) to retrieve raw data (not necessarily HTML markup) from javascript?

Alternatively

An alternative approach that could totally work is exposing an Asp.net Core API which i can simply call from javascript side.

Upvotes: 0

Views: 1143

Answers (1)

Kapil Ghimire
Kapil Ghimire

Reputation: 101

You can not call view components using http(Ajax) but you can have action method on controller will can return view component out put as resut

Upvotes: 1

Related Questions