有做过asp.net 伪静态的例子 要c#代码的、给小弟学习一下、最好有demo 发送邮箱到 [email protected]在留下你在csdn的名称 立即给分 在线的等、、、
解决方案 »
- connection这样创建的优缺点是什么
- 添加引用
- 如何在加载页面后在刷新一次页面 而不会递归的??
- 求com991205源代码
- <DataList>控件中的<ItemTemplate>项能否在cs文件中找到它得绑定的具体值?
- 关于ASP.NET提取通过TCP/IP传输过来的数据问题!!
- 请教在网页中怎么把多张图片在网页中组合成一个动画来播放?
- Js开新窗口问题,请求帮助
- 如何把"_"编码成 "%5F",就是如何把字符串编成cookie里面允许的字符串?
- asp.net下,我要单击LinkButton后,转到另外一个网页,在LinkButton_Click事件中,
- asp.net 水晶报表出现的问题
- 请问我用asp.net下载 可是下载的文件名为乱码有什么办法解决吗
web.config: <system.web>
<httpModules>
<add name="UrlRewrite" type="UrlRewrite.Rewrite, UrlRewrite" />
</httpModules>
</system.web>
Rewrite.cs:
using System;
using System.Web;namespace UrlRewrite
{
/**//// <summary>
/// Rewrite 的摘要说明。
/// </summary>
public class Rewrite:System.Web.IHttpModule
{
public Rewrite()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
IHttpModule 成员#region IHttpModule 成员 public void Init(HttpApplication context) {
// TODO: 添加 Rewrite.Init 实现
context.BeginRequest +=new EventHandler(context_BeginRequest);
} public void Dispose() {
// TODO: 添加 Rewrite.Dispose 实现
} #endregion private void context_BeginRequest(object sender, EventArgs e) {
HttpApplication app = (HttpApplication)sender;
app.Context.RewritePath("your url");//aa.aspx
}
}
}
只需要在Global.asax.cs 的加上Application_BeginRequest
protected void Application_BeginRequest(Object sender, EventArgs e)
{
string oldUrl = HttpContext.Current.Request.RawUrl ;
string pattern = @"^(.+)default/(\d+)\.shtml(\?.*)*$";
string replace = "$1default.aspx?id=$2";
if(Regex.IsMatch(oldUrl, pattern, RegexOptions.IgnoreCase | RegexOptions.Compiled))
{
string newUrl = Regex.Replace(oldUrl, pattern, replace, RegexOptions.Compiled | RegexOptions.IgnoreCase);
this.Context.RewritePath(newUrl);
}
}
然后在IIS中修改Shtml的映射
c:\windows\microsoft.net\framework\v2.0.50727\aspnet_isapi.dll
去掉检查文件是否存在的选择
实现:
default.aspx?id=123
重写为
default/123.shtml