我有以下部分的代碼PartsController:ASP.net MVC資源無法找到
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
我的信息搜索結果視圖存儲在瀏覽/配件/ SearchResult.aspx。但是,當我運行該應用程序時,我收到資源無法找到請求URL/PartsController /搜索
問題2:有人可以指向我的VB教程(S)顯示在視圖中搜索的結果?也就是說,我需要關於如何將SearchResult視圖放在一起的示例,以便它只從我的表中檢索搜索字符串中匹配的項目。
非常感謝您的幫助!
的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
請注意,這個程序是在Windows 2003服務器(IIS6)上運行。我應該對global.asax做進一步修改嗎?再次
感謝, 希德
如何你的路由定義的,你能不能請張貼呢? – 2009-12-15 07:04:42
還有什麼我應該添加到global.asax?謝謝:) – SidC 2009-12-16 16:08:19
請參閱http://stackoverflow.com/questions/9293778/asp-net-mvc-resource-cannot-be-found-error不同的問題 – Lijo 2012-10-24 10:52:46