实现伪静态后站内链接的问题
根据网上教程,web.cinfig配置更改如下:
<configSections>
<section name= "RewriterConfig " type= "URLRewriter.Config.RewriterConfigSerializerSectionHandler, URLRewriter " />
</configSections>
<connectionStrings>
<add name= "123Conn " connectionString= "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\\123.mdb "
providerName= "System.Data.OleDb " />
</connectionStrings>
<system.web>
<RewriterConfig>
<Rules>
<RewriterRule>
<LookFor> ~/xgmv(.[0-9]*)\.aspx </LookFor>
<SendTo> ~/xgmv.aspx?id=$1 </SendTo>
</RewriterRule>
<RewriterRule>
<LookFor> ~/wyzp(.[0-9]*)\.aspx </LookFor>
<SendTo> ~/wyzp.aspx?id=$1 </SendTo>
</RewriterRule>
<RewriterRule>
<LookFor> ~/zfmt(.[0-9]*)\.aspx </LookFor>
<SendTo> ~/zfmt.aspx?id=$1 </SendTo>
</RewriterRule>
<RewriterRule>
<LookFor> ~/zgtp(.[0-9]*)\.aspx </LookFor>
<SendTo> ~/zgtp.aspx?id=$1 </SendTo>
</RewriterRule>
</Rules>
</RewriterConfig>
<httpHandlers>
<add verb= "* " path= "*.aspx " type= "URLRewriter.RewriterFactoryHandler, URLRewriter " />
</httpHandlers>
问题是网站做好后设置的伪静态链接
现在打开站内链接还是和以前一样,伪静态链接也能用,比如:
点击站内链接,出现的URL是:http://10.10.28.150/xgmv.aspx?ID=10
在地址栏输入:http://10.10.28.150/xgmv10.aspx
也能用
怎样才能让站内链接也更改为:http://10.10.28.150/xgmv10.aspx
[解决办法]
在xgmv.aspx.cs文件中加入:
protected override void Render(HtmlTextWriter writer)
{
string id = Request.Params[ "ID "];
if(id != null)
Response.Redirect( "xgmv " + id + ".aspx ", true);
}