我有這樣的方法:檢查發件人是否@ Html.ActionLink
void myMethod(object sender, DownloadStringCompletedEventArgs e)
{...}
我有時通過調用它@ Html.ActionLink,有時通過點擊表格的單元格,其具有類'clickableCell'。 如何檢查發件人是什麼,如果是鏈接?
它的類型都是WebClient。
我有這樣的方法:檢查發件人是否@ Html.ActionLink
void myMethod(object sender, DownloadStringCompletedEventArgs e)
{...}
我有時通過調用它@ Html.ActionLink,有時通過點擊表格的單元格,其具有類'clickableCell'。 如何檢查發件人是什麼,如果是鏈接?
它的類型都是WebClient。
調用它時你可以傳遞一個用戶狀態對象:
var client = new WebClient();
client.DownloadStringCompleted += myMethod;
// You could pass any object
string state = "foo bar";
client.DownloadStringAsync(new Uri("http://foo.bar.com"), state);
然後:
void myMethod(object sender, DownloadStringCompletedEventArgs e)
{
// will equal "foo bar"
string state = e.UserState as string;
...
}
但我不能這樣做。在這兩種情況下,我都有相同的方法。一旦我通過Response.Redirect(Url.Action(「act」,「contr」))調用它,並且一次通過
@Srcee,在這種情況下,您必須將一個額外的查詢字符串參數傳遞給此操作它可以區分這兩種情況。例如:'Url.Action(「act」,「contr」,new {value =「case1」})'或其他。 – 2012-01-18 09:30:56
不能添加此信息到'DownloadStringCompletedEventArgs'? – gdoron 2012-01-18 09:14:52
@DavidePiras你的意思是另一個參數? – 2012-01-18 09:16:45