所以我在控制器中使用了這種方法,我通過javascript調用,但出現錯誤500:內部服務器錯誤。當我嘗試直接通過我的URL訪問該方法時,要查看問題出在哪裏,我看到該參數始終以空值傳遞。參數仍然爲空,即使當我在URL中輸入時
代碼如下:
控制器(參數EditTimeBeforeIdle應該是一個常規的INT,但我暫時改變了它用於調試目的):
[Authorize]
public class IdleController : BafcareController
{
private readonly ISystemUnitOfWork _systemUnitOfWork;
private readonly ICurrentUser _currentUser;
private readonly User _user;
public IdleController(ISystemUnitOfWork systemUnitOfWork, ICurrentUser currentUser)
{
_systemUnitOfWork = systemUnitOfWork;
_currentUser = currentUser;
_user = _systemUnitOfWork.UserRepository.GetUserById(_currentUser.User.Id);
}
public int EditTimeBeforeIdle(int? time)
{ //<-- Breakpoint here to check, time == null
_user.TimeBeforeIdle = time;
_systemUnitOfWork.UserRepository.Update(_user);
ModelSessionHelper.TimeBeforeIdle = time.Value;
return time.Value;
}
}
}
的URL我直接去是
因此,你可以看到參數不應該爲空,那爲什麼呢?
親切的問候
你是如何配置路由的? – Patrick 2015-02-11 14:48:00