首先設定 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 | } |