Skip to main content
 首页 » 编程设计

c#之Intelligencia UrlRewriter 强制小写 URL

2024年02月20日19sxdcgaq8080

在重写时强制使用小写 URL 的最佳方法是什么?

  • Global.asax?
  • web.config?

一切都失败了……我做错了什么?请参阅以下内容:

Global.asax

不知道用什么方法?

void Application_BeginRequest(object sender, EventArgs e) 
    { 
        HttpContext context = HttpContext.Current; 
        string path = Request.Path.ToLower(); 
 
        context.RewritePath(path); 
    } 

web.config

我试过使用 web.config 方法但无法管理:

<rewrite url="(.*)$" to="$1" permanent="true" /> 

如何更改上面的代码,使其自动将 url 强制为小写?

请您参考如下方法:

您是否尝试过 IIS 的 URL 重写模块?

http://www.iis.net/download/urlrewrite

小写有一个特殊的规则: