开发者

How can I get RouteData values on a cached request in ASP.NET MVC?

开发者 https://www.devze.com 2023-04-03 14:47 出处:网络
I´m trying to get the following code to work: RouteData data = context.Request.RequestContext.RouteData;

I´m trying to get the following code to work:

RouteData data = context.Request.RequestContext.RouteData;

if (data == null)
    dat开发者_开发知识库a = RouteTable.Routes.GetRouteData(new HttpContextWrapper(context.Context));

    var name = data.DataTokens["Name"].ToString();

But seems that when I got a cached request ([OutputCache]d) the RouteData is unavailable, and I can´t even manage to get it using GetRouteData() on the route table.

Does anyone have some luck with that?

0

精彩评论

暂无评论...
验证码 换一张
取 消