什么是从控制器获得的基本URL的最佳方式 [英] what is the best way to get the base URL from a controller
本文介绍了什么是从控制器获得的基本URL的最佳方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的控制器如何将我得到的基本URL。
例如,如果我的网址是:
http://www.mysite.com/MyController/MyAction
我想有一个返回的功能:
http://www.mysite.com
解决方案
我使用的:
Request.Url.GetLeftPart(UriPartial.Authority);
Inside my controller how would i get the base URL.
for example, if my url is:
http://www.mysite.com/MyController/MyAction
I want to have a function that returns :
http://www.mysite.com
解决方案
I use:
Request.Url.GetLeftPart(UriPartial.Authority);
这篇关于什么是从控制器获得的基本URL的最佳方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文