2010-03-26 28 views

回答

1

更簡單的方法可能是:

string file = System.IO.Path.GetFileName(Request.Url.LocalPath); 
+0

這種做法將打破,如果你的Web服務請求使用它(例如在Request.Url.LocalPath是像「/Services/SomeService.asmx/SomeFunction」)。 – 2010-03-26 21:00:19

1

我不知道最好的方法,但像

System.IO.Path.GetFilename(Request.CurrentExecutionFilePath) 

會考慮到可能發生的任何Server.Transfer() ING,並會很好地處理Web服務請求。

相關問題