how can we make url starts with# using attribute routing in mvc5

拜拜、爱过 提交于 2020-01-07 04:16:08

问题


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();
}

回答1:


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.




回答2:


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

try Url.Action

return Redirect(Url.Action("Index", "Home") + "#testing");


来源:https://stackoverflow.com/questions/27542532/how-can-we-make-url-starts-with-using-attribute-routing-in-mvc5

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!