Rasoul Zabihi
Rasoul Zabihi

Reputation: 2715

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

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("Countries") in Area B, how ASP.NET MVC knows that I'm talking about a view which belongs to Area A?

Upvotes: 2

Views: 145

Answers (1)

Ufuk Hacıoğulları
Ufuk Hacıoğulları

Reputation: 38468

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.

Upvotes: 1

Related Questions