get the page name from url
https://stackoverflow.com/questions/1874532/better-way-to-get-page-name
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 AppRelativeVirtualPath property 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 Server.MapPath 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.
get the page name from url的更多相关文章
- 修正Thinkphp 3.2 分页Page类以支持URL路由
http://www.thinkphp.cn/topic/22114.html 最终目的实现以http://www.fl900.com/product/lists/1-0-0-1.html这样的URL ...
- Dynamics 365 联系人Contact的快速创建窗体,如何知道父窗体是哪个实体,通过window.top.parent.Xrm.Page.getUrl()可以知道父窗体的URL
Dynamics 365 联系人Contact的快速创建窗体,如何知道父窗体是哪个实体?相信有人会遇到过这种头疼的问题,我这里分享一种方式: 在contact快速创建窗体的onload时间执行如下代码 ...
- github page+jekyll搭博客初体验
div.oembedall-githubrepos { border: 1px solid #DDD; list-style-type: none; margin: 0 0 10px; padding ...
- python 爬取乌云所有厂商名字,url,漏洞总数 并存入数据库
需要:MySQLdb 下面是数据表结构: /* Navicat MySQL Data Transfer Source Server : 127.0.0.1 Source Server Version ...
- paip.uapi 获取网络url内容html 的方法java php ahk c++ python总结.
paip.uapi 获取网络url内容html 的方法java php ahk c++ python总结. 各种语言总结比较,脚本php.python果然是方便.简短,实用. uapi : get_w ...
- 从Wep page到Application
需要做一个选择,是Web app还是Native app,当然,还有第三种,Hybrid app. 现在手机用户越来越多,电脑终端浏览器也在不断的更新换代,推陈出新,网页已经不仅仅是用来分享信息这么简 ...
- Get URL parameters & values with jQuery
原文: http://jquery-howto.blogspot.jp/2009/09/get-url-parameters-values-with-jquery.html In this post, ...
- C# 根据URL返回HTML_根据URL获取图片信息/缩略图
/// <summary> /// 根据URL 返回HTML /// </summary> private List<string> GetHtmlByUrl(st ...
- Header() in PHP &html – Refresh (Redirect) to Location (URL) in X seconds
Case 1 : Redirect a page to a URL without waiting in PHP. 1 header("Location: index.php"); ...
随机推荐
- percona-toolkit工具安装
1.yum安装 yum install perl-TermReadKey.x86_64 yum install perl-IO-Socket-SSL yum install perl-DBI.x86_ ...
- AR+ 实时音视频通话,虚拟与现实无缝结合
今年中旬 Google 在万众期待下推出了 ARCore,能将现实与数码完美无缝地融合在一起,丰富我们的现实世界.通过它开发者可以更加快速方便地在 Android 平台开发 AR 应用,凭借 AR 技 ...
- vscode安装插件
十分简单,知道名字叫啥后,直接搜索,安装,就完了,还可以查看自己已经安装了哪些插件. step1 如图.png step2 image.png step 3 去网上查找想要安装的插件的名字 step ...
- 解决静态utils里面注入mapper对象
项目中需要在一个utils工具类中,调用mapper对象来进行功能实现,然而静态方法里面直接注入会报空指针的错误,网上查了一些资料得出如下解决办法 重点步骤: 1,utils类上面添加@Compone ...
- java多线程调试
1. 多线程调试 https://blog.csdn.net/bramzhu/article/details/52367052 https://www.jb51.net/article/129632. ...
- yum安装LAMP环境与管理
yum安装LAMP环境与管理 参考:http://www.zixue.it/ yum添加163源 地址: http://mirrors.163.com/.help/centos.html 下载方式: ...
- kafka调试中遇到Connection to node -1 could not be established. Broker may not be available.
https://blog.csdn.net/Mr_Hou2016/article/details/79484032
- zookeeper一二三
1.zookeeper介绍 ZooKeeper 是一个开源的分布式协调服务,由雅虎创建,是 Google Chubby 的开源实现.分布式应用程序可以基于 ZooKeeper 实现诸如数据发布/订阅. ...
- java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet
新建Maven 项目的时候报错: java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet ...
- Linux源代码分析工具-Source Insight
下载地址:http://www.sourceinsight.com/down35.html 可用注冊码:SI3US-205035-36448 使用说明:http://wenku.baidu.com/v ...