【发布时间】:2011-02-01 14:28:49
【问题描述】:
我对 ASP.NET MVC 还很陌生,我希望这不是一个太愚蠢的问题。所以它来了。
我有...
- 域类似于http://mydomain/mysubfoler1/myappfolder 的 ASP.NET MVC 应用程序
我的问题...
- 我的应用程序的路由(在域名后不使用子文件夹的情况下,它运行良好)。应用程序主页加载不错,有 css 文件,但没有像图像这样的资源(在 css 文件中定义),也没有类似于 /mycontroller/myaction 的 jQuery ajax 调用
- 链接只能使用一次(我第二次得到类似此链接的页面:http://mydomain/mysubfoler1/myappfolder/myController/myController/myAction)
- jquery ajax 调用 不起作用。 (我在脚本文件夹中有额外的 js 文件,它们正在调用多个控制器操作。p.e.
$.getJSON("../mycontroller/myaction/" + id, function(figure) {
// do something
});
这是我的 Global.asax 包含路由:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default",
"{controller}/{action}/{id}",
new { controller = "myController", action = "Index", id = "" }
defaults
);
routes.MapRoute(
"Root",
"",
new { controller = "myController", action = "Index", id = "" }
);
}
protected void Application_Start()
{
ViewEngines.Engines.Clear();
ViewEngines.Engines.Add(new MyApplicationWeb.LocalizationWebFormViewEngine());
RegisterRoutes(RouteTable.Routes);
//RouteDebug.RouteDebugger.RewriteRoutesForTesting(RouteTable.Routes);
}
有什么建议吗?我的第一个建议是使用以下区域:
"mysubfolder1/myappfolder/{controller}/{action}/{id}"
(但没有任何运气)
非常感谢您的帮助!
【问题讨论】:
-
您能详细说明您的问题吗?我对问题是什么感到有些困惑。是不是你的图片没有加载?
标签: jquery asp.net-mvc routing