UrlRewriter做伪静态后,原来页面出错后会跳转到error.aspx,便是做完伪静态后,就不会跳转到error.html这个页面了(error.aspx已经做到伪静态),页面出错在web.config中已写好,代码出下:
<customErrors mode="Off" defaultRedirect="GenericErrorPage.html">
<!--无法访问错误-->
<error statusCode="403" redirect="GenericErrorPage.html" />
<!--找不到文件错误-->
<error statusCode="404" redirect="GenericErrorPage.html" />
</customErrors>
现在我做完伪静态,比如访问一个不存在的页面报404,不会跳到出错在页面,还有一个问题就是,取一个不存在的id也不会跳!
5 个解决方案
#1
规则呢,,伪静态的规则贴上来嘛
#2
<RewriterConfig>
<Rules>
<RewriterRule>
<LookFor>~/jingpinnr_(.[0-9]*)\.html</LookFor>
<SendTo>~/jingpinnr.aspx?id=$1</SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/more_(.[0-9]*)\.html</LookFor>
<SendTo>~/more.aspx?type=$1</SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/default.html</LookFor>
<SendTo>~/default.aspx</SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/jingpin.html</LookFor>
<SendTo>~/jingpin.aspx</SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/jingpinnr.html</LookFor>
<SendTo>~/jingpinnr.aspx</SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/GenericErrorPage.html</LookFor>
<SendTo>~/GenericErrorPage.aspx</SendTo>
</RewriterRule>
</Rules>
</RewriterConfig>
#3
customErrors mode="on" 这个。。是on还是off?
#4
是ON,但是改过来后,程序会报错,RewriterFactoryHandler.cs这个文件出错,出错代码为:
context.Trace.Write("RewriterFactoryHandler", "Exiting RewriterFactoryHandler"); // log info to the Trace object...
return PageParser.GetCompiledPageInstance(url, filePath, context);
文件不存在的错误。
#5
有人知道吗?
#1
规则呢,,伪静态的规则贴上来嘛
#2
<RewriterConfig>
<Rules>
<RewriterRule>
<LookFor>~/jingpinnr_(.[0-9]*)\.html</LookFor>
<SendTo>~/jingpinnr.aspx?id=$1</SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/more_(.[0-9]*)\.html</LookFor>
<SendTo>~/more.aspx?type=$1</SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/default.html</LookFor>
<SendTo>~/default.aspx</SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/jingpin.html</LookFor>
<SendTo>~/jingpin.aspx</SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/jingpinnr.html</LookFor>
<SendTo>~/jingpinnr.aspx</SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/GenericErrorPage.html</LookFor>
<SendTo>~/GenericErrorPage.aspx</SendTo>
</RewriterRule>
</Rules>
</RewriterConfig>
#3
customErrors mode="on" 这个。。是on还是off?
#4
是ON,但是改过来后,程序会报错,RewriterFactoryHandler.cs这个文件出错,出错代码为:
context.Trace.Write("RewriterFactoryHandler", "Exiting RewriterFactoryHandler"); // log info to the Trace object...
return PageParser.GetCompiledPageInstance(url, filePath, context);
文件不存在的错误。
#5
有人知道吗?