请问在asp.net2.0下如何把扩展名变为.mspx
比如 http://www.microsoft.com/windows/default.mspx
就要这样效果就可以,谢谢!
------解决方案--------------------------------------------------------
可以啊,使用Rewriter
------解决方案--------------------------------------------------------
在IIS管理器里把.mspx映射到Aspnet_isapi.dll 上,参考
http://support.microsoft.com/kb/308001/zh-cn
http://blogs.msdn.com/gduthie/archive/2007/03/14/custom-file-extensions-in-asp-net-2-0.aspx
------解决方案--------------------------------------------------------
需要在IIS设置,想改成什么就改成什么.
------解决方案--------------------------------------------------------
在IIS中设置或都URL重写,想改成什么样都行
------解决方案--------------------------------------------------------
开始 》 运行 》 inetmgr 》 网站/虚拟目录 》右键 》 属性 》 主目录/虚拟目录 》 配置 》 映射 》 添加 》
可执行文件:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll
扩展名:.mspx
------解决方案--------------------------------------------------------
<CustomConfiguration>
<urls>
<add virtualUrl= "~/microsoft*.* " destinationUrl= "~/default.aspx " />
<add virtualUrl= "~/microsoft* " destinationUrl= "~/default.aspx " />
<add virtualUrl= "~/m/i/c/rosoft.aspx " destinationUrl= "~/default.aspx " />
</urls>
</CustomConfiguration>
------解决方案--------------------------------------------------------
1.可执行文件:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll
扩展名:.mspx
同时去掉确认文件存在前的勾
2.如果你的实际文件名是以.mspx结尾的,添加
<compilation>
<buildProviders>
<add extension= ".mspx " type= "System.Web.Compilation.PageBuildProvider "/>
</buildProviders>
</compilation>
<httpHandlers>
<add verb= "* " path= "*.mspx " type= "System.Web.UI.PageHandlerFactory "/>
</httpHandlers>
3. 如果你的实际文件名是以.aspx结尾的,在global.asax里(或者用urlrewrite):
<%@ Application%>
<script language=C# runat= "server ">
const string ASPX_EXT = ".aspx ";
const string MSPX_EXT = ".mspx ";
const string REWRITE_KEY = "Rewrite ";
protected void Application_BeginRequest(Object sender, EventArgs E)
{
string url = Context.Request.RawUrl.ToLower();
if (url.IndexOf(MSPX_EXT) > 0)
{
Context.Items[REWRITE_KEY] = true;
url = url.Replace(MSPX_EXT,ASPX_EXT);
Context.RewritePath(url);
}
}
protected void Application_PreRequestHandlerExecute(Object sender, EventArgs E)
{
if (Context.Items[REWRITE_KEY] != null)
Context.RewritePath(Context.Request.RawUrl);
}
</script>