简体   繁体   中英

Where does HTML.RenderAction is executed?

I tried to find a clear answer, but could not. Where does the helper method such as Html.RenderAction() and Html.Partial() are executed? at the server or the client side? Is the razor code, executed locally?

If on the server, is there a client-side alternative?

Thanks

Razor runs on the server, and generates HTML. This HTML is then sent to the client.

If you want to render or change HTML on the client, you'll need to do so using JavaScript. You could for example serialize your model into JSON and store that in a JavaScript variable :

<script>
    var myModel = @JsonConvert.SerializeObject(someObject);
</script>

Then you can access myModel from JavaScript to do whatever you want, for example bind it to a clientside MVC framework such as Angular or Ember.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM