0
我想從我的web應用程序url中刪除「.aspx」。我也使用webservices。修剪.aspx時,Web服務不工作.aspx
如果我使用下面的代碼Web服務不起作用。
的Global.asax
protected void Application_BeginRequest(object sender, EventArgs e)
{
String WebsiteURL = Request.Url.ToString();
String[] SplitedURL = WebsiteURL.Split('/');
String[] Temp = SplitedURL[SplitedURL.Length - 1].Split('.');
// This is for aspx page
if (!WebsiteURL.Contains(".aspx") && Temp.Length == 1)
{
if (!string.IsNullOrEmpty(Temp[0].Trim()))
Context.RewritePath(Temp[0] + ".aspx");
}
}
的如: -
實際頁面是Default.aspx的,但我想顯示在地址欄默認。所以我使用Global.asax來刪除(.aspx)。它工作正常。但Web服務不起作用(Default.asmx)
歡迎來到堆棧溢出:-) 請看[問] 和[mcve]。這將有助於獲得有用的答案。 – JimHawkins
請將您評論中的信息添加到問題中(通過'edit'question)。您不應該致電其他成員閱讀所有關於尋找解決方案的問題的評論。 – JimHawkins
我會考慮使用IIS的['URLRewrite'](http://www.iis.net/learn/extensions/url-rewrite-module)模塊。不一定是最容易使用,但非常強大,並會做我相信你想要的 – freefaller