我正在學習ASP.NET MVC 2,並且專注於「Ajax和客戶端腳本」。理解錯誤「值不能爲空」錯誤
我剛纔所書下面寫的代碼如下:
public class MVCAJAXLearningsController : Controller
{
private Dictionary<string, double> offsets = new Dictionary<string, double> { { "utc", 0 }, { "bst", 1 }, { "mdt", -6 }, { "ist", 5.5 } };
public ActionResult Index()
{
return View();
}
public ActionResult GetTime(string zone)
{
DateTime time = DateTime.UtcNow.AddHours(offsets[zone]);
if (Request.IsAjaxRequest())
{
string fragment = string.Format("<div>The time in {0} is {1:hh:MM:ss tt}</div>", zone.ToUpper(), time);
return Content(fragment);
}
else
{
return View(time);
}
}
}
我收到以下錯誤。
這又如何解決呢?
+1:具體來說,「zone」參數沒有被填充。 – StriplingWarrior
嗨,謝謝你的回覆。是的,你說得對(我猜)。我怎樣才能傳遞參數?你能建議我嗎... –