问题描述
context.MapRoute("authorized-credit-card", "owners/{ownerKey}/authorizedcreditcard/{action}",
new { controller = "authorizedcreditcard", action = "index" },
new { ownerKey = nameFormat }, dataTokens: new { scheme = Uri.UriSchemeHttps });
在我的路由文件我有一种以上的干线
In my route file I am having above kind of Route.
所以,可以在任何一个可以告诉我什么是 dataTokens的含义是:?新{方案= Uri.UriSchemeHttps
So, could any one tell me what is the meaning of dataTokens: new { scheme = Uri.UriSchemeHttps
?
和控制器的操作方法内上述 dataTokens
的使用情况如何?
And usage of above dataTokens
inside the controller's action method ?
推荐答案
据的:
您使用DataTokens属性检索或分配与不用于确定路由是否一个URL模式相匹配的路由相关的值。这些数值被传递给路由处理,在那里他们可用于处理请求
所以DataTokens是一种可与路线传递的附加数据的。有3 DataToken的键是predefined(类下面来ASP.NET MVC 4,但相同的密钥的形式源$ C $ C版本2时):
So DataTokens is kind of additional data which can be passed with the route. There are 3 DataToken's keys being predefined (the class below comes form source code of ASP.NET MVC 4 but the same keys are used in version 2):
internal class RouteDataTokenKeys
{
public const string UseNamespaceFallback = "UseNamespaceFallback";
public const string Namespaces = "Namespaces";
public const string Area = "area";
}
我不认为框架使用DataToken命名为计划,所以就很难回答你的问题。您可能想要搜索的自定义应用程序code为 DataTokens [方案]
,看看,为什么它是需要的。
I don't think the framework uses DataToken named "scheme" so it is difficult to answer your question. You may want to search your custom application code for DataTokens["scheme"]
and see where and why it is needed.
编辑:
我发现 SSL支持。有使用计划数据令牌的例子。所以我pretty确保您的应用程序使用它非常相同的方式。
I've found an article on "Adding HTTPS/SSL support to ASP.NET MVC routing". There is an example of using "scheme" data token. So I'm pretty sure that your application uses it in the very same way.
这篇关于为什么dataTokens是路由?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!