我对.net很缺乏经验,刚开始学习MVC.我遇到了一个有关找到多个控制器的问题:
"找到了与名为'reviews'的控制器匹配的多个类型.如果为此请求提供服务的路由('{controller}/{action}/{id}')未指定名称空间来搜索匹配的控制器,则会发生这种情况.如果是这种情况,请通过调用带有'namespaces'参数的'MapRoute'方法的重载来注册此路由."
我最近在我的应用程序中添加了一个新的"Admin"区域,其中我有一个"ReviewController".主app文件夹中还有一个"ReviewController":
啊 - 作为一个新用户,我无法发布图像,但基本上我在"控制器"和"区域/管理员/控制器"中有一个"ReviewController".
到目前为止我设置了2条路线:
Global.asax.vb中的默认路由
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}, _
{"PowellCasting/Controllers"}
)
End Sub
Sub Application_Start()
AreaRegistration.RegisterAllAreas()
System.Data.Entity.Database.SetInitializer(New System.Data.Entity.DropCreateDatabaseIfModelChanges(Of Models.PowellCastingEntites))
Database.SetInitializer(Of PowellCastingEntites)(New PowellCastingInitializer())
RegisterGlobalFilters(GlobalFilters.Filters)
RegisterRoutes(RouteTable.Routes)
ControllerBuilder.Current.DefaultNamespaces.Add("PowellCasting/Controllers")
End Sub
Run Code Online (Sandbox Code Playgroud)
AdminAreaRegistration中的区域路由
Namespace PowellCasting.Areas.Admin
Public Class AdminAreaRegistration
Inherits AreaRegistration …Run Code Online (Sandbox Code Playgroud) 我正在使用requireJS和一个CDN版本的jQuery(现在是推荐的方法)组建一个框架,并在优化代码时遇到一些问题.输出是命名空间的,我指定每个模块使用文档中概述的jquery的私有版本:
require.config({
// Add this map config in addition to any baseUrl or
// paths config you may already have in the project.
map: {
// '*' means all modules will get 'jquery-private'
// for their 'jquery' dependency.
'*': { 'jquery': 'jquery-private' },
// 'jquery-private' wants the real jQuery module
// though. If this line was not here, there would
// be an unresolvable cyclic dependency.
'jquery-private': { 'jquery': 'jquery' }
}
});
// and the 'jquery-private' module, in the …Run Code Online (Sandbox Code Playgroud) areas ×1
asp.net-mvc ×1
javascript ×1
jquery ×1
optimization ×1
requirejs ×1
routes ×1
vb.net ×1