在ASP.NET MVC我如何使用从C#code剃刀@ Url.Content()帮助? [英] In ASP.NET MVC how can I use the Razor @Url.Content() helper from C# code?

查看:115
本文介绍了在ASP.NET MVC我如何使用从C#code剃刀@ Url.Content()帮助?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图写一个HTML辅助扩展,输出图像标记。
我需要访问(C#code内)类似Razor的@ Url.Content()辅助,以获得正确的URL为当前上下文。
怎样才能做到这一点?

I'm trying to write a html helper extension that outputs an image tag. I need to access (within C# code) something like Razor's @Url.Content() helper to get the proper URL for the current context. How does one do this?

推荐答案

使用下面的模仿Url.Content在code。

Use the following to mimic Url.Content in code.

VirtualPathUtility.ToAbsolute("~/url/");

这篇关于在ASP.NET MVC我如何使用从C#code剃刀@ Url.Content()帮助?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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