【发布时间】:2012-01-04 20:11:25
【问题描述】:
在下文中,我试图在名为 _p 的类级别上定义一个私有变量。索引的 HTTP.POST 将带来一个用户提供的值,我将使用它来设置这个私有变量。在名为 ListOfVehicles 的第二个方法中,我将访问这个变量。
现在理论上一切都很好,但是当我尝试访问这个私有变量时,我什么也没得到,这是什么都找不到。
Public Class QuotationController
Inherits System.Web.Mvc.Controller
'Private Variables
Dim _p As String
'Get Basic pickup and dropoff details
Function Index() As ActionResult
Return View()
End Function
'Function to get basic details out of the view
'and to redirect to ListOfVehicles
<HttpPost()>
Function Index(ByVal P As String, ByVal D As String) As ActionResult
_p = P
Return RedirectToAction("ListOfVehicles")
End Function
'Show list of vehicels
Function ListofVehicles() As ActionResult
ViewData("UserChoice") = "Pickup: " & _p
vehicleList = QB.GetQuotation(_p, _d)
Return View(vehicleList)
End Function
End Class
【问题讨论】:
标签: asp.net asp.net-mvc variables private