I have the latest versions of VS 2010, .NET 4.0, and MVC 3, and I have a problem using scopes in asp.net mvc 3 when using vb.net.
I do the following:
- Create a new asp.net mvc 3 visual base project. Choose Razor as "View Engin" and invoke the "TestApp" project.
- Create a new area called "Test", it will be located in the folder: / Areas / Test.
- Add a new empty controller called "PageController.vb" to / Areas / Test / Controllers / ".
- Add a new folder to / Areas / Test / Views / called the "Page".
- Add a new blank view called "Index.vbhtml" to / Areas / Test / Views / Page.
- Run the project.
- Manually enter the URL "http: // localhost: xyz / Test / Page" in the browser, where xyz is the automatically added number of ports generated by VS.
In step 7, I get the message "Resource cannot be found."
If I do exactly the same thing using C #, then I will go to the correct page and it will show the word "Index" as expected.
Is this a mistake, or am I missing something? I am browsing the web for hours trying to solve this problem, but I am getting it now.
This is an automatically generated file TestAreaRegistration.vb Namespace TestApp.Areas.Test Public class TestAreaRegistration Inherits AreaRegistration
Public Overrides ReadOnly Property AreaName() As String Get Return "Test" End Get End Property Public Overrides Sub RegisterArea(ByVal context As System.Web.Mvc.AreaRegistrationContext) context.MapRoute( _ "Test_default", _ "Test/{controller}/{action}/{id}", _ New With {.action = "Index", .id = UrlParameter.Optional} _ ) End Sub End Class
Final namespace
And this is the automatically generated Global.ascx file: 'Note. Instructions for enabling IIS6 or IIS7 classic mode, 'visit http://go.microsoft.com/?LinkId=9394802
Public class MvcApplication Inherits System.Web.HttpApplication
Shared Sub RegisterGlobalFilters(ByVal filters As GlobalFilterCollection) filters.Add(New HandleErrorAttribute()) End Sub 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 = UrlParameter.Optional} _ ) End Sub Sub Application_Start() AreaRegistration.RegisterAllAreas() RegisterGlobalFilters(GlobalFilters.Filters) RegisterRoutes(RouteTable.Routes) End Sub
Final class
They are identical to what you get if you repeat steps 1-7 and use C # (the only difference is that you will get C # code equal to the vb.net code above).
I repeat: if I do steps 1-7 in C #, it works, but it will not work in vb.net! What's wrong?