기본적으로 제목이 말합니다. 새로운 MVC 애플리케이션을 만들었습니다. 나는 사이트에 새로운 페이지를 추가하기 위해 노력하고있어,하지만 언제 나는 다음과 같은 오류를받을 수 있나요 : 여기 ASP.Net MVC에서 새로운 컨트롤러 또는 뷰를 사용할 수 없습니다.
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: /Products
은 ProductsController가라는 내 컨트롤러입니다.
namespace MyAppMVC.Controllers
{
public class ProductsController : Controller
{
public ActionResult Index()
{
return View("Index");
}
}
}
또한
return View();
을 시도했다 그러나 그것은 작동하지 않았다.
내보기는 Index.aspx라고하며보기/제품 폴더에 있습니다.
모든 것이 나에게 잘 보이는 것처럼 보였습니다. NerdDinners 자습서를 살펴본 결과 나 외에 다른 것을하지는 않습니다. 앱과 함께 제공되는 홈 컨트롤러를 살펴본 결과 내 모습이 동일하게 보입니다. 나는 라우팅에 아무 것도 추가 할 필요가 없다고 확신하지만, 아마도 그렇게 할 것이다.
아이디어가 있으십니까? 이것은 저를 난처하게했습니다. 요청에 따라
여기 내 global.asax.cs이
public class MvcApplication : System.Web.HttpApplication
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
}
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
RegisterRoutes(RouteTable.Routes);
}
}
Global.asax.cs 파일에서 RegisterRoutes 메서드를 추가 할 수 있습니까? 그냥 확인하십시오 – Thomas
요청에 따라 global.asax.cs 파일을 추가했습니다. –