开发者

How to use one view, in two ASP.NET MVC areas?

开发者 https://www.devze.com 2023-04-13 09:56 出处:网络
I have an ASP.NET MVC application, and in it, I have set up two areas. However, there is one view that I have implemented in Area A, but I also need to use it in Area B. How can I render it in Area B?

I have an ASP.NET MVC application, and in it, I have set up two areas. However, there is one view that I have implemented in Area A, but I also need to use it in Area B. How can I render it in Area B? I mean, Html.RenderPartial method takes the name of the view as the input parameter. But how it's gonna know which view do I mean? In other words, if my view's name is Countries, and I want to write Html.RenderPartial(开发者_JAVA百科"Countries") in Area B, how ASP.NET MVC knows that I'm talking about a view which belongs to Area A?


You can place that partial view in Shared folder inside Views folder(the views folder in the project directory, not area). ASP.NET MVC will check that place and you wouldn't need to define any path. You can use Html.RenderPartial("SomePartial"); in your view.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号