Display full url for default route in Asp Mvc website

前端 未结 1 1857
时光取名叫无心
时光取名叫无心 2021-01-22 15:53

I would like to display the full URL when someone navigates to the root of my website. If they navigate to www.mysite.com, the default routing properly handles it and displays t

1条回答
  •  [愿得一人]
    2021-01-22 16:41

    The only solution I could find was to check in the controller for the current URL and redirect if it was the root.

    var url = Request.RawUrl;
    if (url == @"/")
    {
        Response.Redirect("/Unity/Hygiene");
    }
    return View();
    

    0 讨论(0)
提交回复
热议问题