I have a PartsController with the following partial code:
Function Search(ByVal searchtext As String, ByVal SearchType As String) As ActionResult
If SearchType = "PARTNAME" Then
Dim SearchResult = From p In _entities.PartList _
Where p.PARTNAME = searchtext _
Select p
Return View()
End If
If SearchType = "NSN" Then
Dim SearchResult = From p In _entities.PartList _
Where p.NSN = searchtext _
Select p
Return View()
End If
Return View("UnknownType")
End Function
Function Result(ByVal id As String, ByVal SearchResult As String) As ActionResult
Return View(SearchResult)
End Function
My SearchResult view is stored in Views/Parts/SearchResult.aspx. However, when I run the application, I receive Resource Cannot Be Found Requested URL /PartsController/Search
Question 2: Can someone point me to VB tutorial(s) that display results of a search in a view? That is, I need examples of how to put together the SearchResult view so that it retrieves only the items from my table where there's a match in the search string.
Thanks much for your help!
Global.asax:
' Note: For instructions on enabling IIS6 or IIS7 classic mode,
' visit http://go.microsoft.com/?LinkId=9394802
Public Class MvcApplication
Inherits System.Web.HttpApplication
Shared Sub RegisterRoutes(ByVal routes As RouteCollection)
routes.IgnoreRoute("{resource}.axd/{*pathInfo}")
' MapRoute takes the following parameters, in order:
' (1) Route name
' (2) URL with parameters
' (3) Parameter defaults
routes.MapRoute( _
"Default", _
"{controller}/{action}/{id}", _
New With {.controller = "Home", .action = "Index", .id = ""} _
)
routes.MapRoute( _
"Root", _
"", _
"(controller)/(action)/(id)", _
New With {.controller = "Home", .action = "Index", .id = ""} _
)
End Sub
Sub Application_Start()
RegisterRoutes(RouteTable.Routes)
End Sub
End Class
Note that this app is running on a Windows 2003 server (IIS6). Are there any further modifications I should make to global.asax?
Thanks Again, Sid