I want to lear to use mvc4 on vs11 beta professional version
- I created an ASP.NET MVC 4 WEB APPLICATION
- I select the Empty template
-
I create a controller called c1
Namespace MvcApplication3 Public Class c1 Inherits System.Web.Mvc.Controller ' ' GET: /c1 Function Index() As ActionResult Return View() End Function Function Hello() As String Return "Hello" End Function End Class End Namespace -
I run the application and in the browser URL i write “http://localhost:49653/c1/hello”
but i get this error:
Server Error in ‘/’ Application.
The resource cannot be found. Description: HTTP 404. The resource
you are looking for (or one of its dependencies) could have been
removed, had its name changed, or is temporarily unavailable. Please
review the following URL and make sure that it is spelled correctly.Requested URL: /c1/hello
Version Information: Microsoft .NET Framework Version:4.0.30319;
ASP.NET Version:4.0.30319.17379
What am I doing wrong?? Why it is not working?
With the
DefaultControllerFactoryits not enough to inherit fromSystem.Web.Mvc.Controllerbut your controller name have to end with the word “Controller” (it’s a built in convention)Rename your
c1toc1Controllerand it should work: