ASP.NET页面静态化之URL重写 (转)
有关于URL的重写,本文也只是拿来主意。相继有MS的组件“URLRewriter”和在Global.asax里的“Application_BeginRequest()”编码方式,以及IIS里的ISAPI设置。
娜列下来,实现方法也都很简单。
方法一:MS组件
这里也不用详解了,相关请看:
http://www.microsoft.com/china/msdn/library/webservices/asp.net/URLRewriting.mspx
用法很简单,只需要把组件URLRewriter.dll拷到应用程序的bin目录下,然后在web.config下加入如下代码:
在<configuration></configuration>中加入:
<configSections>
<sectionname="RewriterConfig"type="URLRewriter.Config.RewriterConfigSerializerSectionHandler, URLRewriter"/>
</configSections>
<RewriterConfig>
<Rules>
<RewriterRule>
<LookFor>~/("d{4})/("d{2})/Default".aspx</LookFor>
<SendTo>~/Default.aspx?ID=$1</SendTo>
</RewriterRule>
</Rules>
</RewriterConfig>
然后在<system.web></system.web>中加入:
<httpHandlers>
<addverb="*"path="*.aspx"
type="URLRewriter.RewriterFactoryHandler, URLRewriter"/>
</httpHandlers>
最后在地址栏上键入:http://localhost/Test/2004/12/News.aspx
效果出来了。
上面的<LookFor>~/("d{4})/("d{2})/News".aspx</LookFor>这句这正则表达式URL,即被重写的URL,而<SendTo>~/Default.aspx?ID=$1</SendTo>这一句
相关文档:
1)创建txt文件【web.config】
--------------------------------------------------------------------
<appSettings>
<add key="EditChars" value="D:\Site\ZJPS\TextFile\EditChars.txt"/>
</appSettings>
2) 页面的CS文件中:
--------------- ......
Asp.net日期字符串格式化显示--DateTime.ToString()用法详解
我们经常会遇到对时间进行转换,达到不同的显示效果,默认格式为:2006-6-6 14:33:34
如果要换成成200606,06-2006,2006-6-6或更多的格式该怎么办呢?
这里将要用到:DateTime.ToString的方法(String, IFormatProvider)
示例:
using System;
using Syste ......
61.产生一个int数组,长度为100,并向其中随机插入1-100,并且不能重复。
int[] intarr=new int[100];
arraylist mylist=new arraylist();
random rnd=new random();
while(mylist.count<100)&nb ......
81.什么是soap,有哪些应用。
答:simple object access protocal,简单对象接受协议.以xml为基本编码结构,建立在已有通信协议上(如http,不过据说ms在搞最底层的架构在tcp/ip上的soap)的一种规范web service使用的协议..
82.c#中 property 与 a ......