Determine the model of a partial view from the controller within MVC

前端 未结 5 1776
长情又很酷
长情又很酷 2020-12-13 10:12

My current problem is that I have a partial view that I want to determine what model is being used by it.

I have had to deal with a few strange scenarios for my pro

5条回答
  •  清歌不尽
    2020-12-13 10:58

    I'm not 100% sure that this is what you'd be looking for, but the [ChildActionOnly] attribute can be added to a method within your controller. That requires that the method can only be called from a partial view. Then you can set up your partial view for that method that basically resembles one of your widgets. Check out the MVC Music Store example here:

    http://www.asp.net/mvc/tutorials/mvc-music-store-part-10

提交回复
热议问题