在我的MVC应用程序中,我调用HttpUnauthorizedResult类并指定statusDescription参数.
if (!canAdd) {
return new HttpUnauthorizedResult("You do not have access to add");
}
Run Code Online (Sandbox Code Playgroud)
这也重定向了AccountController上的Login方法,然后我将它们重定向到适当的屏幕.
public ActionResult Login(string returnUrl)
{
if (WebSecurity.IsAuthenticated)
{
return RedirectToAction("AccessDenied");
}
ViewBag.ReturnUrl = returnUrl;
return View();
}
Run Code Online (Sandbox Code Playgroud)
我的问题是如何利用Status Descripton参数,在AccessDenied视图中显示这些细节会很好.
我正在尝试查询 mongo db 中的二进制字段。数据如下所示:
{"_id":"WE8fSixi8EuWnUiThhZdlw=="}
Run Code Online (Sandbox Code Playgroud)
我尝试了很多东西,例如:
{ '_id': new Binary( 'WE8fSixi8EuWnUiThhZdlw==', Binary.SUBTYPE_DEFAULT) }
{ '_id': Binary( 'WE8fSixi8EuWnUiThhZdlw==', 0) }
Run Code Online (Sandbox Code Playgroud)
等等
似乎没有任何工作,已经用尽了 google 和 mongo 文档,任何帮助都会很棒。
我在C#中基本乘法和除法遇到了麻烦.
它为((150/336)*460)返回0,但答案应为205.357142857.
我认为这是因为(150/336)是一个小数,而C#将其舍入为0.
如何在考虑所有小数位的情况下正确计算?