"And whoever is removed away from the Fire and admitted to Paradise, he indeed is successful." (The Holy Quran)
Excellent Windows VPS Hosting Imran Baloch MVP, MVB, MCP, MCTS, MCPD
Did your get the solution about your problem? If you donot get it, please post some code about your project. If you got it, can you share it? It may be help others.
Thanks,
Regards
Young Yang
Please mark the replies as answers if they help or unmark if not.
Feedback to us
Namespace Mvc3AreasTest.Areas.Blog
Public Class BlogAreaRegistration
Inherits AreaRegistration
Public Overrides ReadOnly Property AreaName() As String
Get
Return "Blog"
End Get
End Property
Public Overrides Sub RegisterArea(ByVal context As System.Web.Mvc.AreaRegistrationContext)
context.MapRoute( _
"Blog_default", _
"Blog/{controller}/{action}/{id}", _
New With {.action = "Index", .id = UrlParameter.Optional} _
)
End Sub
End Class
End Namespace
DashboardAreaRegistration.vb
Namespace Mvc3AreasTest.Areas.Dashboard
Public Class DashboardAreaRegistration
Inherits AreaRegistration
Public Overrides ReadOnly Property AreaName() As String
Get
Return "Dashboard"
End Get
End Property
Public Overrides Sub RegisterArea(ByVal context As System.Web.Mvc.AreaRegistrationContext)
context.MapRoute( _
"Dashboard_default", _
"Dashboard/{controller}/{action}/{id}", _
New With {.action = "Index", .id = UrlParameter.Optional} _
)
End Sub
End Class
End Namespace
I don't edit any code, This Areas ( Blog / Dashboard ) routing have 404 error.
If I fix the BlogAreaRegistration.vb and DashboardAreaRegistration.vb Namespace [Mvc3AreasTest.Areas.Blog] | [Mvc3AreasTest.Areas.Dashboard] to [Mvc3AreasTest], re-complier,
Areas function will fine.
If I fix the BlogAreaRegistration.vb and DashboardAreaRegistration.vb Namespace [Mvc3AreasTest.Areas.Blog] | [Mvc3AreasTest.Areas.Dashboard] to [Mvc3AreasTest], re-complier,
Areas function will fine.
Yes, this is due to fact that MVC proritize the controllers using
DataTokens
Yes this is bug because in a C# project, VS create controller inside (root)Area folder with correct namespace while in VB project it does'nt. But this is just related to VS template, this is not a
fault/bug of Routing framework.
You can get the same behiviour in C# if you change the namespace of an area controller.
"And whoever is removed away from the Fire and admitted to Paradise, he indeed is successful." (The Holy Quran)
Excellent Windows VPS Hosting Imran Baloch MVP, MVB, MCP, MCTS, MCPD
I just dig into t4 template(which you can be found at C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\ItemTemplates\VisualBasic\Web\MVC 3\CodeTemplates\AddController) for
Add Controller and found that MvcTextTemplateHost.Namespace property is wrong only in MVC 3 VB project case. Neither in MVC 2 VB nor in MVC 3 C#.
I am wondering why Visual Studio using MvcTextTemplateHost object with wrong NameSpace(during executing
ProcessTemplate
method, I am assuming VS uses this method) in only MVC 3 VB case.
Update: I have just checked this on a machine which only have ASP.NET MVC 3 installed (instead of ASP.NET MVC 3
Tools Update) and found no issue. So the issue is specially related with ASP.NET MVC 3
Tools Update.
"And whoever is removed away from the Fire and admitted to Paradise, he indeed is successful." (The Holy Quran)
Excellent Windows VPS Hosting Imran Baloch MVP, MVB, MCP, MCTS, MCPD
kkbruce
Member
55 Points
20 Posts
Mvc3 Areas Can't Running - VB Only
Aug 10, 2011 02:27 AM|LINK
I'm use VB, VS2010, MVC 3.
I create new mvc 3 project, and add new {Areas},
step is {http://msdn.microsoft.com/en-us/library/ee671793%28v=VS.98%29.aspx},
but Areas can't run and 404 error.
I find in the *AreaRegistration.vb, Namespace is error.
Error Namespace is:
Namespace Mvc3Area.Areas.Blog
Namespace Mvc3Area.Areas.Dashboard
but correct is :
Namespace Mvc3Area
I don't know is Mvc3 bug or ???
ps... Only VB have this problem.
imran_ku07
All-Star
45815 Points
7698 Posts
MVP
Re: Mvc3 Areas Can't Running - VB Only
Aug 10, 2011 03:44 AM|LINK
Please show your code.
Excellent Windows VPS Hosting
Imran Baloch MVP, MVB, MCP, MCTS, MCPD
Young Yang -...
All-Star
21343 Points
1818 Posts
Microsoft
Re: Mvc3 Areas Can't Running - VB Only
Aug 15, 2011 07:38 AM|LINK
Hi kkbruce,
Did your get the solution about your problem? If you donot get it, please post some code about your project. If you got it, can you share it? It may be help others.
Thanks,
Regards
Young Yang
Feedback to us
Develop and promote your apps in Windows Store
kkbruce
Member
55 Points
20 Posts
Re: Mvc3 Areas Can't Running - VB Only
Aug 16, 2011 04:10 AM|LINK
This is new mvc3 areas for vb project.
download test project: https://skydrive.live.com/?cid=6909a9b0416ee592&sc=documents&id=6909A9B0416EE592%21401#
I step is [Walkthrough: Organizing an ASP.NET MVC Application using Areas],
BlogAreaRegistration.vb
Namespace Mvc3AreasTest.Areas.Blog Public Class BlogAreaRegistration Inherits AreaRegistration Public Overrides ReadOnly Property AreaName() As String Get Return "Blog" End Get End Property Public Overrides Sub RegisterArea(ByVal context As System.Web.Mvc.AreaRegistrationContext) context.MapRoute( _ "Blog_default", _ "Blog/{controller}/{action}/{id}", _ New With {.action = "Index", .id = UrlParameter.Optional} _ ) End Sub End Class End NamespaceDashboardAreaRegistration.vb
Namespace Mvc3AreasTest.Areas.Dashboard Public Class DashboardAreaRegistration Inherits AreaRegistration Public Overrides ReadOnly Property AreaName() As String Get Return "Dashboard" End Get End Property Public Overrides Sub RegisterArea(ByVal context As System.Web.Mvc.AreaRegistrationContext) context.MapRoute( _ "Dashboard_default", _ "Dashboard/{controller}/{action}/{id}", _ New With {.action = "Index", .id = UrlParameter.Optional} _ ) End Sub End Class End NamespaceI don't edit any code, This Areas ( Blog / Dashboard ) routing have 404 error.
If I fix the BlogAreaRegistration.vb and DashboardAreaRegistration.vb Namespace [Mvc3AreasTest.Areas.Blog] | [Mvc3AreasTest.Areas.Dashboard] to [Mvc3AreasTest], re-complier, Areas function will fine.
This Mvc3 areas problem, only in VB.
imran_ku07
All-Star
45815 Points
7698 Posts
MVP
Re: Mvc3 Areas Can't Running - VB Only
Aug 16, 2011 09:09 AM|LINK
Yes, this is due to fact that MVC proritize the controllers using DataTokens
Yes this is bug because in a C# project, VS create controller inside (root)Area folder with correct namespace while in VB project it does'nt. But this is just related to VS template, this is not a fault/bug of Routing framework.
You can get the same behiviour in C# if you change the namespace of an area controller.
Excellent Windows VPS Hosting
Imran Baloch MVP, MVB, MCP, MCTS, MCPD
imran_ku07
All-Star
45815 Points
7698 Posts
MVP
Re: Mvc3 Areas Can't Running - VB Only
Aug 16, 2011 10:52 AM|LINK
I just dig into t4 template(which you can be found at C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\ItemTemplates\VisualBasic\Web\MVC 3\CodeTemplates\AddController) for Add Controller and found that MvcTextTemplateHost.Namespace property is wrong only in MVC 3 VB project case. Neither in MVC 2 VB nor in MVC 3 C#.
I am wondering why Visual Studio using MvcTextTemplateHost object with wrong NameSpace(during executing ProcessTemplate method, I am assuming VS uses this method) in only MVC 3 VB case.
Update: I have just checked this on a machine which only have ASP.NET MVC 3 installed (instead of ASP.NET MVC 3 Tools Update) and found no issue. So the issue is specially related with ASP.NET MVC 3 Tools Update.
Excellent Windows VPS Hosting
Imran Baloch MVP, MVB, MCP, MCTS, MCPD
ricka6
All-Star
15070 Points
2272 Posts
Microsoft
Moderator
Re: Mvc3 Areas Can't Running - VB Only
Aug 16, 2011 09:10 PM|LINK
Thanks for all your great work on this Imran. We hope to have this fixed in the next version.