Add a trailing slash at the end of each url?

后端 未结 6 654
傲寒
傲寒 2020-12-01 00:15

I have a little problem here. I need to add a trailing slash at the end of each url in the site I\'m working on. I defined all the links inside the site to have a trailing s

6条回答
  •  春和景丽
    2020-12-01 00:51

    There are some really good answers but here is some MVC Controller code of how I implement it in a very simple get.

        public ActionResult Orders()
        {
            if (!Request.Path.EndsWith("/"))
            {
                return RedirectPermanent(Request.Url.ToString() + "/");
            }
            return View();
        }
    

    Hope this helps someone.

提交回复
热议问题