博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
get the page name from url
阅读量:6138 次
发布时间:2019-06-21

本文共 977 字,大约阅读时间需要 3 分钟。

The way I interpret the question what you're looking for is an efficient way of retrieving the name of the currently executing aspx page, ie System.Web.UI.Page.

If that is true you shouldn't have to deal with any FileInfo objects or hit the filesytem. Simply use the on the page object.

using System; using System.IO; using System.Web.UI; namespace WebApplication1 { public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { string pageName = Path.GetFileNameWithoutExtension(Page.AppRelativeVirtualPath); } } }

If you wan't to get the fully qualified (or "rooted") path of your currently executing page you can use like this

string path = Server.MapPath(Page.AppRelativeVirtualPath); //这里的路径是网页对应的物理文件的路径

Using AppRelativeVirtualPath has the benefit of working even when you're using url rewriting and since it doesn't use Request.Url (which is provided by your users) you don't have to worry about potentially malicious data.

 

转载地址:http://pbuya.baihongyu.com/

你可能感兴趣的文章
openstack 虚拟机添加网卡
查看>>
Groovy学习笔记(6)-javax.script.* API
查看>>
RocketMQ服务搭建
查看>>
微信支付 - 可以下单但是无法收到通知消息Log总显示begin notify
查看>>
分享我如何活用notepad++
查看>>
Object-c的基础概念
查看>>
自我关系的建立
查看>>
mysql读取配置文件的顺序
查看>>
《游戏程序设计模式》 2 - 顺序模式
查看>>
数据过滤器注解@Filter 如何在hibernate、spring data jpa中调用
查看>>
Eclipse上GIT插件EGIT使用手册之九_Rebase和Merge的区别
查看>>
关闭进程中打印信息
查看>>
安装memcached软件并用简单脚本做测试
查看>>
MySQL表新增字段默认值处理的一处小细节
查看>>
MEMCACHE TIME_WAIT过多的解决方法
查看>>
CITRIX技术峰会,浦东香格里拉之旅
查看>>
在QNAP NAS上安装pfSense
查看>>
mysql-5.7.21版本一直报错ERROR 1067 (42000)!
查看>>
maven自动建立目录
查看>>
收款业务流程图怎样画
查看>>