how can we make url starts with# using attribute r

2019-09-02 19:55发布

I want to create a url which starts with # like localhost:/#somename. Can anyone help me?

i tried with custom route constraint,i did not get

//localhost:/#testing
[Route(@"{x:regex([^#]*)}testing")]
public ActionResult testingyash(string x)
{
  return View();
}

2条回答
Summer. ? 凉城
2楼-- · 2019-09-02 20:30

You cant have a url like that. The # symbol is a Fragment Identifier. Its used by browsers to identify a section in page. Anything following the # is not even sent to the server.

查看更多
淡お忘
3楼-- · 2019-09-02 20:38

Why do you need routing for # value? Those are client-side values.

try Url.Action

return Redirect(Url.Action("Index", "Home") + "#testing");
查看更多
登录 后发表回答