代码之家  ›  专栏  ›  技术社区  ›  Å¡ljaker

ASP.NET MVC-如何用dash替换%20[[副本]

  •  0
  • Å¡ljaker  · 技术社区  · 16 年前

    可能重复:
    How does StackOverflow generate its SEO-friendly URLs?


    当用户提交表单时,将调用以下路由:
    ~/Profile/NAME

    如果用户输入John Smith作为姓名,我的URL将为:

    我希望它是:
    ~/Profile/约翰·史密斯

    应用程序将在页面顶部显示用户详细信息和相同的表单。
    名称值将通过ViewData传递给表单。
    我想用 约翰·史密斯 约翰·史密斯 .


    提前谢谢!

    我在这里找到了解决方案: http://goneale.com/2008/12/19/lowercase-route-urls-in-aspnet-mvc/ .
    它需要一些修改,但基本上就是这样。

    2 回复  |  直到 9 年前
        1
  •  0
  •   Community Mohan Dere    9 年前

    如果有帮助的话,我用 this

        2
  •  1
  •   Filip Ekberg    16 年前

    HttpUtility 调查 UrlDecode / UrlEncode

    编辑

    <input type="text" value="name" />
    <input type="submit" id="submit" />
    

    jQuery

    $('submit').click(function() {
     $('name').val($('name').val().replace(' ', '-'));
    });