Does a view exist in ASP.NET MVC?

前端 未结 7 764
粉色の甜心
粉色の甜心 2020-11-28 09:59

Is it possible to determine if a specific view name exists from within a controller before rendering the view?

I have a requirement to dynamically determine the name

7条回答
  •  孤独总比滥情好
    2020-11-28 10:59

    Here's another [not necessarily recommended] way of doing it

     try
     {
         @Html.Partial("Category/SearchPanel/" + Model.CategoryKey)
     }
     catch (InvalidOperationException) { }
    

提交回复
热议问题