zoukankan
html css js c++ java
学习URLRewriter.dll的使用
1.添加引用
2.配置webconfig
webconfig
1
<?
xml version="1.0" encoding="utf-8"
?>
2
<
configuration
>
3
4
<
configSections
>
5
<
section
name
="RewriterConfig"
type
="URLRewriter.Config.RewriterConfigSerializerSectionHandler, URLRewriter"
/>
6
</
configSections
>
7
8
<
RewriterConfig
>
9
<
Rules
>
10
<
RewriterRule
>
11
<
LookFor
>
~/News/(\d+)\.aspx
</
LookFor
>
12
<
SendTo
>
~/default.aspx?id=$1
</
SendTo
>
13
</
RewriterRule
>
14
</
Rules
>
15
</
RewriterConfig
>
16
17
<
system.web
>
18
19
<
httpHandlers
>
20
<
add
verb
="*"
path
="*.aspx"
type
="URLRewriter.RewriterFactoryHandler, URLRewriter"
/>
21
</
httpHandlers
>
22
23
<
compilation
debug
="true"
/>
24
25
<
authentication
mode
="Windows"
/>
26
</
system.web
>
27
28
</
configuration
>
29
3.测试
测试
1
public
partial
class
_Default : System.Web.UI.Page
2
{
3
public
string
id;
4
protected
void
Page_Load(
object
sender, EventArgs e)
5
{
6
id
=
Request.QueryString[
"
id
"
].ToString();
7
}
8
protected
void
Button1_Click(
object
sender, EventArgs e)
9
{
10
Response.Write(GetCategory());
11
}
12
13
string
GetCategory()
14
{
15
if
(Request.PathInfo.Length
==
0
)
16
{
17
return
""
;
18
}
19
else
20
{
21
return
Request.PathInfo.Substring(
1
);
22
}
23
}
24
}
最后,发现重写的目的达到了。但是,单击button时路径暴露了。
接着查资料...
人的一生应该这样度过:当他回首往事的时候,不会因为虚度年华而悔恨,也不会因为碌碌无为而羞愧。
查看全文
相关阅读:
最近邻插值
tp类型自动转换和自动完成
tp读取器和写入器
tp模型和数据库操作方法
tp数据库操作
tp请求和响应
tp配置+路由+基本操作
git的常见操作方法
php 检查该数组有重复值
公众号的TOKEN配置PHP代码
原文地址:https://www.cnblogs.com/htht66/p/1141193.html
最新文章
选择 Python3.6 还是 Python 3.7
Beta 冲刺(1/7)
pytorch:EDSR 生成训练数据的方法
Beta
事后诸葛亮--Alpha版本总结
团队冲刺Alpha(十)
团队冲刺Alpha(九)
团队冲刺Alpha(八)
团队冲刺Alpha(七)
团队冲刺Alpha(六)
热门文章
团队Alpha冲刺(五)
函数定义
存储类
LapSRN
VDSR
pandas nan值处理
pandas 时间格式转换
双系统安装Ubuntu
KL散度
SRCNN
Copyright © 2011-2022 走看看