为什么ViewContext.ViewName不可用?

时间:2010-01-11 17:43:43

标签: asp.net-mvc vb.net viewcontext

我在网上看了几个使用以下代码的例子:

Private Function SomeFunction(ByVal htmlhelper As HtmlHelper) As String
    Dim controller As Controller = htmlhelper.ViewContext.Controller

    If controller IsNot Nothing Then
        Dim vname as String = htmlhelper.ViewContext.ViewName 'This doesnt work
    End If
End Function

ViewContext没有名为ViewName的成员。我错过了什么吗?

参考文献: http://blog.eworldui.net/post/2008/05/ASPNET-MVC---Localization.aspx
Asp.Net MVC: How to determine if you're currently on a specific view
http://groups.google.com/group/spark-dev/browse_thread/thread/e5d9e8264c66ba57

1 个答案:

答案 0 :(得分:2)

看起来ViewName在测试期间被删除了。这是两个解决方法:

http://forums.asp.net/p/1334617/2694729.aspx