我是 Asp.net MVC 的新手。我对我的自定义 URL 路由问题感到震惊。我创建了名为“Customer”的控制器,并将操作创建为“DisplayCustomer”。在 Global.asax.cs 页面中,
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
namespace MvcApplication1
{
// Note: For instructions on enabling IIS6 or IIS7 classic mode,
// visit http://go.microsoft.com/?LinkId=9394801
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 = "Customer",
action = "DisplayCustomer",
id = UrlParameter.Optional
}); // Parameter defaults//, new { Code = @"\d{1001,1002}" }
}
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
RegisterRoutes(RouteTable.Routes);
}
}
}
我不知道它有什么问题,它总是显示为
http://localhost:50415/Views/Customer/DisplayCustomer.aspx
不像
http://localhost:50415/Customer/DisplayCustomer
我是否错过了使它起作用的东西?