1

我目前正在编写一个 ping 状态监控 ASP。但我不知道如何将数据从调用动作传递给控制器​​。

我的操作代码如下:-

Function showPing2(ByVal ipaddress As String) As String
    If ipaddress = 1 Then
        Return "Online"
    Else
        Return "Offline"
    End If
End Function

从 Index.vbhtml 调用方法

        @Html.Action("showPing2(1)")

我无法传递这样的值,它一直显示错误“用户代码未处理 HttpException”

谁能告诉我如何在 ASP .NET 中正确传递值?

非常感谢你!!

4

1 回答 1

1

语法错误,试试这个:

@Html.Action("showPing2", new { ipaddress = "1" })

或者

@Html.Action("showPing2", "ControllerName", new { ipaddress = "1" })

添加

这是我从匿名类型(Visual Basic)VB.Net 中的匿名类初始化中C#了解的语法,VB.NET 类似于:

@Html.Action("showPing2", New With { .ipaddress = "1" })
于 2012-10-03T09:23:39.167 回答