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"); ...
随机推荐
- [图文教程] 使用Git 提交项目到码云
目录 1. 环境准备 2. 开发工具配置Git和SSH 3. 配置SSH到码云 4. 创建一个项目 5. Clone项目到本地 6. Push项目到码云 1. 环境准备 1.1 本机配置Git Hom ...
- mysql数据库中的索引有那些、有什么用
本文主要讲述了如何加速动态网站的MySQL索引分析和优化. 一.什么是索引? 索引用来快速地寻找那些具有特定值的记录,所有MySQL索引都以B-树的形式保存.如果没有索引,执行查询时MySQL必须从第 ...
- Backspace doesn't delete inner html tags of a contenteditable DIV in Firefox
https://bugzilla.mozilla.org/show_bug.cgi?id=439808 backspace键 在ff下不能使用 div contenteditable=true时
- 洛谷 P 1018 乘积最大 ==Codevs
题目描述 今年是国际数学联盟确定的“2000――世界数学年”,又恰逢我国著名数学家华罗庚先生诞辰90周年.在华罗庚先生的家乡江苏金坛,组织了一场别开生面的数学智力竞赛的活动,你的一个好朋友XZ也有幸得 ...
- Java开发一些小的思想与功能小记(二)
1.用if+return代替复杂的if...else(if+return) public static void test1(String str) { if ("1".equal ...
- 哀悼改变全站颜色为灰色CSS代码收藏
<style type="text/css"> *{ filter:progid:DXImageTransform.Microsoft.BasicIma ...
- oracle alert 日志位置
Oracle 11g Alert log 文件位置的问题 https://blog.csdn.net/yujin2010good/article/details/7690191 https://blo ...
- python学习之 - 时间模块
时间模块模块名:time时间模块的转换流程图. UTC:英国格林威治时间.时间戳作用:是用来进行时间计算的.进行加减时间.注意:时间计算是用秒为单位time.process_time():测量处理器运 ...
- 2018 江苏省邀请赛 H
题目链接 https://nanti.jisuanke.com/t/28872 解析 递推 直接套杜教板子 AC代码 #include <cstdio> #include <cstr ...
- css三大布局
标准流: 从左到右,从上到下块级元素独占一行,行内元素碰到父盒子边缘换行 浮动: 特点 1 元素浮动之后不占据原来的位置(脱标),变成立体,下面可以有东西,只影响下面的 2 浮动的盒子在一行上显示 3 ...