0
我只花了時間今晚使用this guide現有的ASP.NET Web窗體應用程序轉換爲MVC3。然而,當我去啓動應用程序只是爲了在本地運行應用程序來檢查我的工作,我得到這個錯誤:如何調試ASP.NET MVC3應用程序,會拋出錯誤,並在Global.asax中不打斷點?
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:/
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.237
我已經嘗試設置各種斷點,在我的Global.asax,我懷疑我把路由器搞砸了,但是斷點沒有被擊中。因爲它不是打在這個文件我的斷點,然後我的假設是,我並不需要雙方都期待在控制器或視圖,因爲進一步的下跌的執行路徑。
我的文件夾結構包含以下文件夾和文件:
Controllers\
HomeController.cs
Models\
Views\
Home\
Index.cshtml
Shared\
_Layout.cshtml
Error.cshtml
_ViewStart.html
Global.asax
web.config
web.config
這裏是在Global.asax的內容:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
namespace www
{
public class MvcApplication : System.Web.HttpApplication
{
public static void RegisterGlobalFilters(GlobalFilterCollection filters)
{
filters.Add(new HandleErrorAttribute());
}
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
//ignore aspx pages (web forms take care of these)
routes.IgnoreRoute("{resource}.aspx/{*pathInfo}");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}", // URL with parameters
// Parameter defaults
new { controller = "Home", action = "Index"}
);
}
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
RegisterGlobalFilters(GlobalFilters.Filters);
RegisterRoutes(RouteTable.Routes);
}
}
}
\ \控制器HomeController.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace www.Controllers
{
public class HomeController : Controller
{
public ActionResult Index()
{
return View();
}
}
}
我是比較新的ASP.NET MVC和Visual Studio所以不知道從哪裏開始調試THI秒。任何提示將不勝感激。
您是說其「Global.asax的」,但你的命名空間被命名爲「WWW」。怎麼樣??? –
該項目的名稱是「www」。 – TMC
你確定bin位於正確的目錄嗎?如果,所有的dll都部署了嗎? – Peter