在 Global.asax 中添加 Application_BeginRequest 事件:
復(fù)制代碼代碼如下:
protected void Application_BeginRequest(object sender, EventArgs e)
{
string pathAndQuery = Request.Url.PathAndQuery.ToLower();
if (pathAndQuery.IndexOf(".html") > -1)
{
pathAndQuery = "~/" + pathAndQuery.Replace(".html", ".aspx");
HttpContext.Current.RewritePath(pathAndQuery);
}
}
這樣就可以用xxx.html 來(lái)訪問(wèn)你的 xxx.aspx頁(yè)面了,瀏覽器地址欄顯示的是xxx.html(頁(yè)面帶參數(shù)也是可以的)。