I need to return a PartialView through API call

I need to return a PartialView through API call

this is my Ajax Request

$.ajax({
			url: 'sampleurl',
			type: 'POST',
			headers: { 'litium-request-context': JSON.stringify(window.__litium.requestContext) },
			cache: false
		}).done(function(html) {
			debugger;
			var cart = $('.js-minicart');
			if (cart.length && $(html).length) {
				cart.html($(html).html());
			}
		});

In the Api controller I created an object of home controller and tried to return the parital view

    public class HomeController : ControllerBase
    {
	    private readonly RequestModelAccessor _requestModelAccessor;

	    public HomeController(HomeViewModelBuilder builder, AuthorizationService authorizationService,
			RequestModelAccessor requestModelAccessor, HeaderViewModelBuilder<HeaderViewModel> headerViewModelBuilder)
        {
	        _requestModelAccessor = requestModelAccessor;
        }
[HttpPost]
        public ActionResult Index()
        {
	        var currentArea = _requestModelAccessor.GetWebsiteArea();
	        var partialView = PartialView($"~/Areas/{currentArea}/Views/Shared/Framework/_partialView.cshtml");
	        return partialView;
        }

	}

but in ajax I am not getting the html, instead I am getting the Object.

So I tried another method, in the ajax method for url: I called
site.axd/controller/method
and it reaches the method in controller, but _requestModelAccessor is disposed and I am not able to continue.

Need some help here.

I don’t think it is possible to do, I think you need to use an Mvc-controller to be able to return the PartialView as html.

I have already tried that,
and I had mentioned that above, but _requestModelAccessor is null.

also another thing I noticed is here,
in view when I use
<input type=“hidden” id=“hdnId” value="@Url.Action(“ControllerName”,“ActionName”)"/>
the value is empty string.

Check out the answer on How to access RequestModel while using a custom controller (site.axd)? - #2 by patric.forsgard regarding the null request model accessor.

Try to use the parameters in the correct order, regarding to Microsofts implementation the action is always the first parameter.

sorry, It was a typing mistake, I mean its not working this way too

You mean with the Url.Action? Please, provide a running minimal example and we can investigate.