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时路径暴露了。
接着查资料...
人的一生应该这样度过:当他回首往事的时候,不会因为虚度年华而悔恨,也不会因为碌碌无为而羞愧。
查看全文
相关阅读:
备份与还原SQL Server 数据库
ASP网站发布到IIS上注意问题
MySQL相关积累
C#中 让日历控件dateTimePicker1显示你想要的日期
C#,右击鼠标,窗体出现在鼠标右边
c#中combobox绑定数据库成功(方法二)
java web 编写资料
windows下使用gethostbyname函数报错无法解析的外部符号
C语言中的作用域,链接属性和存储类型
二级指针的用法
原文地址:https://www.cnblogs.com/htht66/p/1141193.html
最新文章
doctype(文档类型)的作用是什么?转载
js如何判断一个对象是不是Array?(转载)
前段笔试(转载)
面试之响应式布局(转载)
面试之hack(转载)
面试之ajax原理(转载)
面试之get和post(转)
js中赋值表达式的值为右边
php的几种运行模式CLI、CGI、FastCGI、mod_php
windows 安装mongodb2
热门文章
windows 删除无用服务
windows 安装mongodb
ArrayAccess 接口(源码)
什么是 Trait
PHP 中的Closure
CentOS 7 yum方式快速安装MongoDB
mongodb centos7 安装
Docker的save和export命令的区别
ASP.NET中将文件以二进制的形式保存到SQLServer数据库
ASP.NET知识点
Copyright © 2011-2022 走看看