zoukankan      html  css  js  c++  java
  • mvc中让路由忽略带后缀的路径文件

     1 public static void RegisterRoutes(RouteCollection routes)
     2 {
     3 routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
     4 routes.Ignore("{*allfiles}", new { allfiles = @".*.(.*)(/.*)?" });
     5 //routes.MapRoute(
     6 // name: "Default",
     7 // url: "{controller}/{action}/{id}",
     8 // defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
     9 //);
    10 
    11 routes.MapRoute(
    12 "Default", // Route name
    13 "{controller}/{action}/{id}", // URL with parameters
    14 new { controller = "Home", action = "Index", id = UrlParameter.Optional },
    15 new string[] { "WebApplication1.Controllers" } // Parameter defaults // Parameter defaults
    16 );
    17 }

    比如在mvc中使用webService 如果不添加routes.Ignore("{*allfiles}", new { allfiles = @".*.(.*)(/.*)?" });你是无法访问调用webservice中的方法的

     
  • 相关阅读:
    C#学习(四)
    C#学习(三)
    sqlserver基本操作
    ado.net(1)
    wpf的学习日志(一)
    C#学习(二)
    三大范式
    存储过程
    事务
    范文模板
  • 原文地址:https://www.cnblogs.com/sunalong/p/3411834.html
Copyright © 2011-2022 走看看