我怎样才能获得根域URI在ASP.NET? [英] How can I get the root domain URI in ASP.NET?

查看:130
本文介绍了我怎样才能获得根域URI在ASP.NET?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

比方说,我在主持 http://www.foobar.com 的一个网站。

Let's say I'm hosting a website at http://www.foobar.com.

有没有一种方法,我可以以编程方式在我的code确定http://www.foobar.com/的背后(即无需在我的web配置硬code的话)?

Is there a way I can programmatically ascertain "http://www.foobar.com/" in my code behind (i.e. without having to hardcode it in my web config)?

推荐答案

<一个href=\"http://msdn.microsoft.com/en-us/library/system.web.htt$p$pquest.url.aspx\">HttpContext.Current.Request.Url可以让你的所有URL上的信息。而且可以分解成URL及其片段。

HttpContext.Current.Request.Url can get you all the info on the URL. And can break down the url into its fragments.

这篇关于我怎样才能获得根域URI在ASP.NET?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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