1
The ASP.NET route mapper can route to files or controllers.
ASP.NET路由映射器可以路由到文件或控制器。
Try this example: (you will need to rename your .html file to .aspx, but you dont have to make any other changes to it.)
試試這個例子:(您需要將.html文件重命名為.aspx但不必對其進行任何其他更改。)
In your route config file:
在您的路由配置文件中
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
// route default URL to index.aspx
routes.MapPageRoute(
routeName: "DefaultToHTML",
routeUrl: "",
physicalFile: "~/index.aspx",
checkPhysicalUrlAccess: false,
defaults: new RouteValueDictionary(),
constraints: new RouteValueDictionary { { "placeholder", ""} }
);
// other routes go here...
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller "Home", action "Index", id UrlParameter.Optional }
);
}
}
【文章转自迪拜服务器 http://www.558idc.com/dibai.html处的文章,转载请说明出处】