如何从ASP.NET code当前的URL背后 [英] How to get the current URL from ASP.NET code behind
本文介绍了如何从ASP.NET code当前的URL背后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的应用程序托管在不同的服务器上,我想要得到的网页的URL当前服务器上。
你怎么能得到code这个属性后面?
解决方案
字符串URL = HttpContext.Current.Request.Url.AbsoluteUri;
http://thehost.com/dir/Default.aspx
路径字符串= HttpContext.Current.Request.Url.AbsolutePath;
/dir/Default.aspx
字符串主机= HttpContext.Current.Request.Url.Host;
thehost.com
My application is hosted on different servers, and I want to get the URL of the page on the current server.
How can you get this property in code behind?
解决方案
string url = HttpContext.Current.Request.Url.AbsoluteUri;
http://thehost.com/dir/Default.aspx
string path = HttpContext.Current.Request.Url.AbsolutePath;
/dir/Default.aspx
string host = HttpContext.Current.Request.Url.Host;
thehost.com
这篇关于如何从ASP.NET code当前的URL背后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文