I’ve having a heck of a time figuring out why my routing configuration isn’t work. I tried mysite/issues/500 and mysite/issues/ but i always get a 404 error. I put a breakpoint in both the get functions and it never hits the breakpoint. Thought maybe glimpse could help me but i tried to
Here is my global.asax:
Public Class MvcApplication
Inherits System.Web.HttpApplication
Sub Application_Start()
AreaRegistration.RegisterAllAreas()
RouteTable.Routes.MapRoute("Issues", "{controller}/{id}", New With {.id = UrlParameter.Optional})
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters)
RouteConfig.RegisterRoutes(RouteTable.Routes)
End Sub
End Class
Controller:
Namespace Controllers
Public Class IssuesController
Inherits ApiController
' GET api/issues'
Public Function GetValues(ByVal req As HttpRequestmessage) As IEnumerable(Of Issue)
Dim querystrParams As NameValueCollection = Nothing
Dim srch As IQuery
If req.RequestUri.Query.Any() Then
srch = New IssueTrackerQuery(req.RequestUri.ParseQueryString())
End If
Return (New EnumerableQuery(Of Issue)(New HashSet(Of Issue)))
End Function
' GET api/issues/5'
Public Function GetValue(ByVal IssuesId As Integer) As Issue
Return New Issue()
End Function
' POST api/issues'
Public Sub PostValue(ByVal value As String)
Throw New NotImplementedException()
End Sub
' PUT api/issues/5'
Public Sub PutValue(ByVal id As Integer, ByVal value As String)
Throw New NotImplementedException()
End Sub
' DELETE api/issues/5'
Public Sub DeleteValue(ByVal IssuesId As Integer)
Throw New NotImplementedException()
End Sub
End Class
End Namespace
You don’t have any API routes in your Global.asax. Add one using the
MapHttpRouteextension method (instead ofMapRoute):Notice the
routes.MapHttpRoutewhich registers the web api controllers.