从 url 获取当前页面 [英] get current page from url
本文介绍了从 url 获取当前页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想编写一个 c# 方法来检索当前页面.例如 Default6.aspx 我知道我可以做到以下几点:
I want to write a c# method to retrieve the current page. eg Default6.aspx I know I can do the following:
string url = HttpContext.Current.Request.Url.AbsoluteUri;
// http://localhost:1302/TESTERS/Default6.aspx
string path = HttpContext.Current.Request.Url.AbsolutePath;
// /TESTERS/Default6.aspx
string host = HttpContext.Current.Request.Url.Host;
// localhost
但是我怎样才能得到 Default6.aspx?如果 url 是 http://localhost:1302/TESTERS/,我的方法应该返回 default.aspx
but how can I get Default6.aspx? And if the url is http://localhost:1302/TESTERS/, my method should return default.aspx
推荐答案
Path.GetFileName( Request.Url.AbsolutePath )
这篇关于从 url 获取当前页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文