代码后面的Ajax.BeginForm

Is it possible to use Ajax.BeginForm in the Controller? Cause I want to create a form in the Controller and then write it in the HTML after an AJAX request. Or is there a better way?


Now I use a PartialView but it doesn't work... How can I render it with Ajax?

I'm understanding your question as you want to return an HTML fragment as a response to a client's AJAX request, but do not know how.


Of course there is a better way. It's MVC and you really shouldn't have View code in your Controller unless you truly can't help it. :)

Just create a partial view and render it as a response by return PartialView().