Does a view exist in ASP.NET MVC?

前端 未结 7 746
粉色の甜心
粉色の甜心 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) { }
    
    0 讨论(0)
提交回复
热议问题