我使用ASP.NET MVC与EF 6.
我有一个库存页面,显示库存商品的所有信息.现在我想要过滤记录.
在下图中我有3个选项.我可以按每个选项进行过滤,一次一个,或者两个或全部三个组合.
我正在考虑为所选的每个选项编写linq查询.但是如果过滤器选项增加,这将是不可能的.有更好的方法.
谢谢!
这就是我在我的控制器中所做的.(目前下拉有两个选项,不包括:" - 选择一个 - ")
public ActionResult StockLevel(string option, string batch, string name)
{
if (option != "0" && batch == "" && name == "")
{
if(option == "BelowMin")
{
List<Stock> stk = (from s in db.Stocks
where s.Qty < s.Item.AlertQty
select s).ToList();
return View(stk);
}
else
{
List<Stock> stk = (from s in db.Stocks
where s.Qty == s.InitialQty
select s).ToList();
return View(stk);
}
}
if (option == …
Run Code Online (Sandbox Code Playgroud) 我一直在尝试使用linkedin V2 api,但不断收到错误.我创建了一个开发人员应用 将重定向网址设置为" https://www.getpostman.com/oauth2/callback "以使用邮递员发送请求(根据邮递员文档).填写表单以请求访问令牌.
但每次我使用令牌并进行查询时,都会收到错误消息:
但我已在我的应用程序中选择了所有默认应用程序权限.我错过了什么吗?
我有ASP.NET Core web api项目.现在我想记录错误和事件.我之前在我的项目中使用过ELMAH,但似乎elmah不适用于ASP.NET Core.我提到了 这个官方链接, 用于配置Microsoft提供的默认日志记录服务.我看不到如何将这些日志保存在文本文件或数据库中.
如果ASP.NET Core已经具有默认日志记录功能,我想知道为什么我应该使用其他工具,如elmah,log4net.因此,当我搜索实现默认日志记录以将日志保存在db或文本文件中的文章时,我找不到任何内容.有没有什么方法可以使用ASP.NET核心内置的日志记录支持将日志保存到文件中?
我目前正在使用Serilog,它运行良好,并且还下载了seq,用于在浏览器中优雅地显示日志.但是,我仍然想知道如何使用内置的asp.net核心日志记录功能实现相同的功能.
logging serilog entity-framework-core asp.net-core asp.net-core-logging
我有一个现有的安装项目.最终用户许可证对话框显示虚拟文本(Lorum ipsum)而不是默认协议.我一直在尝试解决这个问题,但我无法弄清楚要改变什么以及如何获得默认的最终用户许可协议?
(我没有发布代码,因为它有很多公司的网址.)
但是这里有一个用于UI节点的块:
<UI Id="MyWixUI_FeatureTree">
<UIRef Id="WixUI_FeatureTree" />
<UIRef Id="WixUI_ErrorProgressText" />
<DialogRef Id="PlatformServiceDlg" />
<DialogRef Id="IMDatabaseDetailsDlg"/>
<DialogRef Id="EmailDatabaseDetailsDlg"/>
<DialogRef Id="SMTPSettingsDlg"/>
<DialogRef Id="EmailRecipientsDlg"/>
<DialogRef Id="ServiceCredentialsDlg"/>
<Publish Dialog="CustomizeDlg" Control="Next" Property="_BrowseProperty" Value="[DATA_DIRECTORY]" Order="1">1</Publish>
<Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="ServiceCredentialsDlg">1</Publish>
</UI>
Run Code Online (Sandbox Code Playgroud)
许可协议如下所示:
我试图构建一个在前端使用webapi 2和 angular js 1的应用程序。我一直在研究安全方面,尤其是基于令牌的安全性。
我可以找到很多东西,但它确实令人困惑要实现什么:OAuth、IdentityServer、HMAC 和 Auth0。
我检查了 HMAC 并通过控制台应用程序使用了 webapi。但是,我一直没能找到前端基于JS的框架使用webapi的项目(比如angular)。通常有很多代码的控制台应用程序。我想知道如何使用 Angular js 来做到这一点?
我检查了 IdentityServer,发现它的学习曲线对于像我这样的新手来说有点令人沮丧。我有现有用户和角色表的现有数据库。我想使用自己的并编写自己的身份验证逻辑,而不是使用 Identity 提供的默认表。但我也无法找到这些资源。
现在我可以看到一个 Auth0。现在在深入研究之前,我想确定它是否是 webapi 可取的身份验证和授权框架。
因为我被要求在项目中实施基于令牌的身份验证。我很难找出正确的方法和最简单的方法。我已经浪费了一个星期,仍然困惑我应该实施什么。因此,如果您有任何资源以优雅的方式执行了 webapi 安全性,请帮助我。
我一直在将我的存储库类映射到它的接口,同样也用于服务.在这里我可以手动注册它们.但我希望我的代码在运行时动态映射这些代码,这样我就不必在每次创建新的存储库或服务时手动注册它们.我怎样才能做到这一点?
这是我的代码:
public void RegisterDependencies(IServiceCollection services, IConectionSetting connectionSetting)
{
services.AddDbContext<QuantumDbContext>(options => options.UseSqlServer(connectionSetting.Get()));
//services.AddDbContext<TestDbContext>(options => options.UseSqlServer(databaseFactory.ConnectionString));
services.AddTransient<IDatabaseFactory, DatabaseFactory>();
services.AddTransient<IDbContext, TestDbContext>();
services.AddTransient<IDbContext, QuantumDbContext>();
services.AddTransient<IUnitOfWorkManager, UnitOfWorkManager>();
services.AddTransient<IRepository<CodeTable>, Repository<CodeTable>>();
services.AddTransient<IRepository<Country>, Repository<Country>>();
services.AddTransient<IRepository<State>, Repository<State>>();
services.AddTransient<IRepository<City>, Repository<City>>();
services.AddTransient<ICodeTableService, CodeTableService>();
services.AddTransient<ICountryService, CountryService>();
}
Run Code Online (Sandbox Code Playgroud) c# dependency-injection entity-framework-core asp.net-core-mvc asp.net-core
我使用创建了 UserActivity 日志记录或审核跟踪ServiceFilter
。我无法使用操作过滤器,因为我需要传递依赖项。
我成功记录了用户的活动。
public class ActivityLog : ActionFilterAttribute
{
private ILogUserActivityService _service;
//injecting specified service to insert the log in database.
public ActivityLog(ILogUserActivityService service)
{
_service = service;
}
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
// Stores the Request in an Accessible object
var request = filterContext.HttpContext.Request;
// Generate the log of user activity
LogUserActivity log = new LogUserActivity()
{
// Username. shall be changed to UserId later afteter Auth management.
UserName = filterContext.HttpContext.User.Identity.Name ?? "Anonymous",
// …
Run Code Online (Sandbox Code Playgroud) 首先,我是一个幼稚的开发者,对这些代码没有太深入的理解。我在尝试获取应用程序之一的版本号的代码块中访问被拒绝。
场景:在 Visual Studio 中运行代码时没有问题。但是,当安装文件在不同的计算机上运行并检查日志时,它会抛出Win32Exception:访问被拒绝。
(程序在安装后立即自动运行。实际上,在安装此应用程序之前,已经安装了一个看门狗服务,该服务会自动运行该应用程序并在关闭时恢复它。所以,我相信我无法将requestedExecutionLevel设置为requireAdmin,它可能会显示确认对话框并给用户对运行应用程序的控制。)
我需要解决这个问题。在阅读了一些博客后,我认为这一定是由于缺乏足够的权限来检索所需信息。但我仍然不清楚如何解决/解决这个问题。
日志文件中的异常:
[ 1,11216] 2017-04-17T11:43:53 - -------------------- Win32Exception caught --------------------
[ 1,11216] 2017-04-17T11:43:53 - Access is denied
[ 1,11216] 2017-04-17T11:43:53 - (Win32Err=0x00000005)
[ 1,11216] 2017-04-17T11:43:53 - Stack trace is :
[ 1,11216] 2017-04-17T11:43:53 - at System.Diagnostics.ProcessManager.OpenProcess(Int32 processId, Int32 access, Boolean throwIfExited)
at System.Diagnostics.NtProcessManager.GetModuleInfos(Int32 processId, Boolean firstModuleOnly)
at System.Diagnostics.NtProcessManager.GetFirstModuleInfo(Int32 processId)
at System.Diagnostics.Process.get_MainModule()
at IMPMDesktopClient.BaseIMClientDriver.GetVersion(UIntPtr windowUIntPtr)
at IMPMDesktopClient.WindowDetector.Hooks.WindowsEventArgs..ctor(Int32 eventNum, UIntPtr windowHandle, Int32 idObject, Int32 idChild, String clsName, Rectangle pos)
at IMPMDesktopClient.WindowDetector.Hooks.EventHooks.CheckForWindowOfInterest(UIntPtr hWnd, …
Run Code Online (Sandbox Code Playgroud) c# ×4
asp.net-core ×3
logging ×2
.net ×1
angularjs ×1
asp.net-mvc ×1
audit-trail ×1
filter ×1
hmac ×1
linkedin-api ×1
linq ×1
oauth ×1
process ×1
serilog ×1
watchdog ×1
wix ×1