现在的位置: 首页 > 综合 > 正文

如何將網址的副檔名(.aspx)隱藏?

2012年12月20日 ⁄ 综合 ⁄ 共 478字 ⁄ 字号 评论关闭

首先設定 IIS  讓所有檔案都由asp.net 執行

按右鍵選內容

 

按設定

 

按新增

 

打上 C:\WINNT\Microsoft.NET\Framework\v1.1.4322\aspnet_isapi.dll 和 *

 

 

在 Global.asax.cs 這個檔寫段程式

1 protected void Application_BeginRequest(Object sender, EventArgs e)  
2 {  
3    string url = System.Web.HttpContext.Current.Request.Path;  
4    string query = System.Web.HttpContext.Current.Request.QueryString.ToString();  
5    if (url.IndexOf(".aspx") == -1)  
6       System.Web.HttpContext.Current.RewritePath(url+".aspx"+ (query.Length > 0?"?"+query:""));  
7 }  
【上篇】
【下篇】

抱歉!评论已关闭.