包括ASP.NET MVC URL路径哈希值 [英] Including hash values in ASP.NET MVC URL routes

查看:163
本文介绍了包括ASP.NET MVC URL路径哈希值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要实现哈希值即URL应该是这样的:

I need to implement hash value i.e the Url should look like this:

/家庭/指数/#创建

/home/index/#create

有关这增加了一个途径:

For this have added a route:

routes.MapRoute(
    "Default",    // Route name
    "{controller}/{action}/#{detail}",    // URL with parameters
    new { controller = "Login", action = "LogIn",  detail  =""}  // Parameter defaults
);

在访问 /家庭/指数/#创建,它被重定向到我的默认路由。

On accessing /home/index/#create, it is redirecting me to the default route.

如何才能做到这一点?

推荐答案

您无法读取,只是因为这个值永远不会被发送到服务器上的符号后的价值服务器。只有JavaScript必须与哈希会这样定义路由接入客户端没有太大的意义。

You cannot fetch the value after the # symbol on the server simply because this value is never sent to the server. Only client side javascript has access to this so defining routes with hash doesn't make much sense.

这篇关于包括ASP.NET MVC URL路径哈希值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆