如何在 ASP.NET MVC 中找到操作的绝对 url? [英] How do I find the absolute url of an action in ASP.NET MVC?

查看:30
本文介绍了如何在 ASP.NET MVC 中找到操作的绝对 url?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要做这样的事情:

<script type="text/javascript">
    token_url = "http://example.com/your_token_url";
</script>

我使用的是 MVC 的 Beta 版本,但我不知道如何获取操作的绝对 url.我想做这样的事情:

I'm using the Beta version of MVC, but I can't figure out how to get the absolute url of an action. I'd like to do something like this:

<%= Url.AbsoluteAction("Action","Controller")) %>

是否有帮助程序或 Page 方法?

Is there a helper or Page method for this?

推荐答案

点击 此处 了解更多信息,但基本上不需要扩展方法.它已经内置了,只是不是以非常直观的方式.

Click here for more information, but esentially there is no need for extension methods. It's already baked in, just not in a very intuitive way.

Url.Action("Action", null, null, Request.Url.Scheme);

这篇关于如何在 ASP.NET MVC 中找到操作的绝对 url?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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