asp.net里面的伪静态怎么做的 用谁知道asp.net里面的伪静态怎么做的,要详细的方法 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 ...2楼是发链接地址 不是就那么几个字...伪静态现在网上例子很多 自己搜索一些流程就是 引用一个urlwrite.dll文件 然后web.config配置映射路径地址就可以了 很简单的 IIS发布时添加映射 就OK了 1.添加 URLRewriter.dll2.webconfig中配置 <configSections> <section name="RewriterConfig" type="URLRewriter.Config.RewriterConfigSerializerSectionHandler, URLRewriter"/> </configSections> <httpModules> <add type="URLRewriter.ModuleRewriter, URLRewriter" name="ModuleRewriter"/> </httpModules>//映射</configSections> <RewriterConfig> <Rules> <RewriterRule> <LookFor>~/url.aspx</LookFor> <SendTo>~/default.aspx</SendTo> </RewriterRule> <RewriterRule> <LookFor>~/url/</LookFor> <SendTo>~/default.aspx</SendTo> </RewriterRule> <RewriterRule> <LookFor>~/url.html</LookFor> <SendTo>~/default.aspx</SendTo> </RewriterRule> <RewriterRule> <LookFor>~/(.*)/(.*)/default.aspx</LookFor> <SendTo>~/default.aspx?page=$1&type=$2</SendTo> </RewriterRule> </Rules> </RewriterConfig>3.页面根据相应重写规则就可以访问对应页面了. asp.net实现伪静态ASP.NET伪静态的实现及伪静态的意义 我要使用 HTTP 模块执行 URL 重写 我要使用 HTTP 模块执行 URL 重写,也就是我们说的伪静态,想要模拟的详细代码 用MVC吧,在Route中可以非常方便的添加规则,可以实现地址目录化,也可以很方便的改变文件后缀 Route吧,貌似WEBFORM也可以用的 没错。部署 一个Global.asax,再在web.config里配置一下这是我的例子:[C#] public class Global : System.Web.HttpApplication { //..... protected void Application_BeginRequest(object sender, EventArgs e) { string originalPath = Context.Request.Path.ToLower(); if (Regex.IsMatch(originalPath, ".htm\\b") && (RewriteUrl(originalPath, "news") || RewriteUrl(originalPath, "gallery") || RewriteUrl(originalPath, "special") || RewriteUrl(originalPath, "shop") || RewriteUrl(originalPath, "albumcenter") || RewriteUrl(originalPath, "newscenter") || RewriteUrl(originalPath, "guestbook") || RewriteUrl(originalPath, "shopdetails") )) { } } bool RewriteUrl(string originalPath, string name) { Regex reg = new Regex(name + "(_(?<id>\\d+))?(_p(?<page>\\d+))?.htm"); var matchs = reg.Matches(originalPath); int id = 0; int page = 0; if (matchs.Count <= 0) return false; page = CommOp.ToInt(matchs[0].Groups["page"].Value); id = CommOp.ToInt(matchs[0].Groups["id"].Value); string request = ""; if (id > 0 && page > 0) { request = "?Id=" + id + "&Page=" + page; } else if (id > 0) { request = "?Id=" + id; } else if (page > 0) { request += "?Page=" + page; } string newPath = reg.Replace(originalPath, name + ".aspx" + request); Context.RewritePath(newPath); return true; } ....[/C#]这是我在做www.aij1.com中的实际应用。 安装了VSS但是总出现下面的问题 求高人指点 为什么我加上主机头后网站就不能访问了 请教:重装xp .net程序不能连接本地数据库 ASP.NET_SessionId问题 请问ASP.NET能转换JSP代码,或者JSP转换为ASP.NET程序吗? IIS ■■一个复杂的页面逻辑用什么工具来设计? ■■ 哪位有简单清洁点的论坛代码 字符串操作 我在.net中调试运行WebForm1.aspx时出错误,请大家帮我看看. xheditor-1.1.13 上传图片报错 都百度一天了!我说大神你就教教我这个菜鸟吧,很菜的一个问题,麻烦了!
伪静态现在网上例子很多 自己搜索一些
流程就是 引用一个urlwrite.dll文件 然后web.config配置映射路径地址就可以了
很简单的 IIS发布时添加映射 就OK了
2.webconfig中配置 <configSections>
<section name="RewriterConfig" type="URLRewriter.Config.RewriterConfigSerializerSectionHandler, URLRewriter"/>
</configSections> <httpModules>
<add type="URLRewriter.ModuleRewriter, URLRewriter" name="ModuleRewriter"/>
</httpModules>//映射
</configSections>
<RewriterConfig>
<Rules>
<RewriterRule>
<LookFor>~/url.aspx</LookFor>
<SendTo>~/default.aspx</SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/url/</LookFor>
<SendTo>~/default.aspx</SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/url.html</LookFor>
<SendTo>~/default.aspx</SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/(.*)/(.*)/default.aspx</LookFor>
<SendTo>~/default.aspx?page=$1&type=$2</SendTo>
</RewriterRule>
</Rules>
</RewriterConfig>3.页面根据相应重写规则就可以访问对应页面了.
asp.net实现伪静态
ASP.NET伪静态的实现及伪静态的意义
部署 一个Global.asax,再在web.config里配置一下这是我的例子:
[C#]
public class Global : System.Web.HttpApplication
{
//.....
protected void Application_BeginRequest(object sender, EventArgs e)
{
string originalPath = Context.Request.Path.ToLower();
if (Regex.IsMatch(originalPath, ".htm\\b") &&
(RewriteUrl(originalPath, "news")
|| RewriteUrl(originalPath, "gallery")
|| RewriteUrl(originalPath, "special")
|| RewriteUrl(originalPath, "shop")
|| RewriteUrl(originalPath, "albumcenter")
|| RewriteUrl(originalPath, "newscenter")
|| RewriteUrl(originalPath, "guestbook")
|| RewriteUrl(originalPath, "shopdetails")
))
{
}
} bool RewriteUrl(string originalPath, string name)
{
Regex reg = new Regex(name + "(_(?<id>\\d+))?(_p(?<page>\\d+))?.htm");
var matchs = reg.Matches(originalPath);
int id = 0;
int page = 0;
if (matchs.Count <= 0) return false; page = CommOp.ToInt(matchs[0].Groups["page"].Value);
id = CommOp.ToInt(matchs[0].Groups["id"].Value);
string request = "";
if (id > 0 && page > 0)
{
request = "?Id=" + id + "&Page=" + page;
}
else if (id > 0)
{
request = "?Id=" + id;
}
else if (page > 0)
{
request += "?Page=" + page;
} string newPath = reg.Replace(originalPath, name + ".aspx" + request); Context.RewritePath(newPath);
return true;
}
....
[/C#]
这是我在做www.aij1.com中的实际应用。