当前位置 : 主页 > 网络编程 > 其它编程 >

C#.netMapRoute到html文件

来源:互联网 收集:自由互联 发布时间:2023-07-02
1TheASP.NETroutemappercanroutetofilesorcontrollers.ASP.NET路由映射器可以路由到文件或控制器。Trythisexample: 1 The ASP.NET route mapper can route to files or controllers. ASP.NET路由映射器可以路由到文件或控制器。
1TheASP.NETroutemappercanroutetofilesorcontrollers.ASP.NET路由映射器可以路由到文件或控制器。Trythisexample:

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处的文章,转载请说明出处】
网友评论