郁闷,这个问题一直困扰着我。楼上的兄弟,就是URL重写呀。没有代码的,只是配置一下而已。难道大家都没有用过URL重写吗?
解决方案 »
- aspx页面传递参数给ascx用户控件
- 用户正常访问的同时;要修改某个页面以及数据,同时又要防止多人同时编辑相同的代码或者数据;
- table未能占满<td></td>标签内的全部空间
- dll 引用的问题
- 请问sql2000可以在WINXP家庭版中安装吗?
- ext.net v1.0 GridPanel 获取选中行的列
- Page load时为什么取不到用户控件的值呢??急
- 有关UDS oa 的问题,高手请进
- CSDN 新加入了使用 Google , QQ, GitHub等账号登陆的功能,请问是怎样实现的呢?有Sample么?
- ASP.NET怎样用ADO组件
- 打开工程失败,错误:Http/1.1 403 forbidden(The server denies the specified Uniform resource locator)
- 关于ASP.Net上传与下载文件的问题
{
// log information to the Trace object.
app.Context.Trace.Write("ModuleRewriter", "Entering ModuleRewriter"); // get the configuration rules
RewriterRuleCollection rules = RewriterConfiguration.GetConfig().Rules; // iterate through each rule...
for(int i = 0; i < rules.Count; i++)
{
// get the pattern to look for, and Resolve the Url (convert ~ into the appropriate directory)
string lookFor = "^" + RewriterUtils.ResolveUrl(app.Context.Request.ApplicationPath, rules[i].LookFor) + "$"; // Create a regex (note that IgnoreCase is set...)
Regex re = new Regex(lookFor, RegexOptions.IgnoreCase); // See if a match is found
if (re.IsMatch(requestedPath))
{
// match found - do any replacement needed
string sendToUrl = RewriterUtils.ResolveUrl(app.Context.Request.ApplicationPath, re.Replace(requestedPath, rules[i].SendTo)); // log rewriting information to the Trace object
app.Context.Trace.Write("ModuleRewriter", "Rewriting URL to " + sendToUrl); // Rewrite the URL
RewriterUtils.RewriteUrl(app.Context, sendToUrl);
break; // exit the for loop
}
} // Log information to the Trace object
app.Context.Trace.Write("ModuleRewriter", "Exiting ModuleRewriter");
}
<Rules>
<RewriterRule>
<LookFor>~/BBS/(\d+)/(\d+)\.html</LookFor>
<SendTo>~/BBS/BrowsePost.aspx?smallid=$1&postid=$2</SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/BBS/(\d+)\.html</LookFor>
<SendTo>~/BBS/PostList.aspx?smallid=$1</SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/BBS/SendPost-(\d+)\.html</LookFor>
<SendTo>~/BBS/SendPost.aspx?smallid=$1</SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/articles/(\d+)\.html</LookFor>
<SendTo>~/site_browsearticle.aspx?articleid=$1</SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/doctors/(\d+)\.html</LookFor>
<SendTo>~/site_browsedoctor.aspx?doctorid=$1</SendTo>
</RewriterRule>
</Rules>
</RewriterConfig><httpModules>
<add name="ScriptModule" type="Microsoft.Web.Services.ScriptModule"/>
<add name="BridgeModule" type="Microsoft.Web.Services.BridgeModule"/>
<add name="WebResourceCompression" type="Microsoft.Web.Services.WebResourceCompressionModule"/>
<add type="URLRewriter.ModuleRewriter, URLRewriter" name="ModuleRewriter" />
</httpModules>
<configSections>
<section name="RewriterConfig" type="URLRewriter.Config.RewriterConfigSerializerSectionHandler, URLRewriter"/>
</configSections>
<connectionStrings>这个有用嘛?