Why is ASP.NET MVC ignoring my trailing slash?

后端 未结 2 1984
感动是毒
感动是毒 2021-01-12 05:16

Consider the following route:

    routes.MapRoute(
        \"Service\", // Route name
        \"service/\", // URL with parameters
        new {controller =          


        
2条回答
  •  长情又很酷
    2021-01-12 06:07

    In your page load event add:

    Dim rawUrl As String = HttpContext.Current.ApplicationInstance.Request.RawUrl
    If Not rawUrl.EndsWith("/") Then
        HttpContext.Current.ApplicationInstance.Response.RedirectPermanent(String.Format("~{0}/", rawUrl))
    End If
    

提交回复
热议问题