嗨,我有以下隐藏在页面上的警报
<div class="alert alert-success" id="selectCodeNotificationArea" hidden="hidden">
<button type="button" class="close" data-dismiss="alert">×</button>
@TempData["selCode"]
</div>
Run Code Online (Sandbox Code Playgroud)
我用以下javascript显示它
$('#send_reject_btn').click(function () {
var selRowIds = $("#ApprovalGrid").jqGrid('getGridParam', 'selarrrow');
if (selRowIds.length > 0) {
$('#reject_alert').show();
} else {
$('#selectCodeNotificationArea').show();
}
});
Run Code Online (Sandbox Code Playgroud)
这显然与我的html中的按钮相关联.
显示警报后,如果我使用<button type="button" class="close" data-dismiss="alert">×</button>
下次关闭它.下次按下按钮打开警报我可以看到$('#selectCodeNotificationArea').show();
在我的调试屏幕中调用,但警报不再显示.
有谁之前经历过这个吗?
我正在尝试在 .Net Core 项目中使用 Serilog。我有 2 个服务,第一个服务是从 .Net Core 2.2 升级的,在 Program.cs 中它使用 IWebHostBuilder 来启动应用程序。在这里,我创建了记录器并将其作为参数传递给 UseSerilog() ,一切都按预期工作。
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.ConfigureServices(services => services.AddAutofac())
.UseStartup<Startup>()
.UseSerilog(_logger);
Run Code Online (Sandbox Code Playgroud)
我的第二个服务是使用 .Net Core 3 模板创建的,它使用 IHostBuilder。当我尝试通过以下任一方式使用 Serilog 时,我会收到相同的错误。
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.UseServiceProviderFactory(new AutofacServiceProviderFactory())
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>()
.UseSerilog(_logger);
});
Run Code Online (Sandbox Code Playgroud)
或者
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.UseServiceProviderFactory(new AutofacServiceProviderFactory())
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
})
.UseSerilog(_logger);
Run Code Online (Sandbox Code Playgroud)
给我这个错误
System.InvalidOperationException:尝试激活“MyService.Startup”时无法解析类型“Microsoft.Extensions.Logging.ILogger`1[MyService.Startup]”的服务。
嗨,我想为我的应用程序捆绑我的脚本.我的调试工作正常,如果我使用Web.debug发布,一切正常.但是当我使用Web.releas发布时,我的脚本不会加载.一切都在本地工作,只有当我从VS2012发布到Azure时才会停止.以下是我创建捆绑包的方法.
namespace BAT.App_Start
{
public class BundleConfig
{
public static void RegisterBundles(BundleCollection bundles)
{
//BundleTable.EnableOptimizations = true;
bundles.Add(new ScriptBundle("~/Content/MasterCss")
.Include("~/Content/bootstrap.css")
.Include("~/Content/bootstrap-responsive.css")
.Include("~/Content/CSS/site.css"));
bundles.Add(new ScriptBundle("~/Scripts/MasterScripts")
.Include("~/Scripts/jquery-{version}.js")
.Include("~/Scripts/bootstrap.js"));
bundles.Add(new ScriptBundle("~/Scripts/Validation")
.Include("~/Scripts/jquery.validate.js")
.Include("~/Scripts/jquery.validate.unobtrusive.js"));
}
}
}
Run Code Online (Sandbox Code Playgroud)
未注释的行打破了调试版本
这是我调用捆绑包的布局
@using System.Web.Optimization
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>@ViewBag.Title Business Analysis Tool </title>
@Styles.Render("~/Content/MasterCss")
</head>
<body>
<div class="container-fluid">
<div class="row-fluid"> @RenderPage("~/Views/Shared/_Header.cshtml") </div>
<div class="row-fluid"> @RenderBody() </div>
<div class="row-fluid"> @RenderPage("~/Views/Shared/_Footer.cshtml") </div>
</div>
@Scripts.Render("~/Scripts/MasterScripts")
@RenderSection("scriptholder", false)
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
这是我的Release.Config
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<system.web>
<compilation …
Run Code Online (Sandbox Code Playgroud) 嗨,我正在使用编码的UI测试(CUIT)来测试应用程序.我尝试过录音选项,这对我来说不够灵活.如果您在不同尺寸的屏幕上使用它,它会中断.
我知道你可以手动编写测试代码,但我找不到任何关于如何编写基本测试的好例子.这里有一些使用CUITe的例子,但是这些帖子来自2011年,我不确定它们与微软对CUIT的新升级有多相关.
这些测试需要与Visual Studio 2012 Ultimate中的构建环境集成,这就是我不使用Selenium的原因.
我们将非常感谢代码示例或指向优秀教程的链接,但特别是我正在寻找一个关于如何开始手工编码我的CUIT的示例
嗨,我正在使用Simple Injector作为我的应用程序DI.我保留了框架DI的默认DI.
但我需要注册DbContext
SimpleInjector.当我运行应用程序时
container.Verify()
Run Code Online (Sandbox Code Playgroud)
给出以下错误
ActivationException:UsersDbContext类型的构造函数包含名称为'options'的参数,并键入未注册的DbContextOptions.请确保已注册DbContextOptions,或更改UsersDbContext的构造函数.
我正在函数中使用SimpleInjectore注册DbContext SimpleInjectorConfig.InitializeContainer(app, _container)
// DbContext
container.Register<DbContext, UsersDbContext>();
Run Code Online (Sandbox Code Playgroud)
而我的创业公司就是
public void ConfigureServices(IServiceCollection services)
{
var conString = Configuration.GetConnectionString("DefaultConnection");
// Add framework services.
services.AddDbContext<UsersDbContext>(options => options.UseSqlServer(conString));
services.AddIdentity<User, IdentityRole>()
.AddEntityFrameworkStores<UsersDbContext>()
.AddDefaultTokenProviders();
IdentityConfigurationService.ConfigureIdentityOptions(services);
services.AddMvc();
// Add application services
services.AddSingleton<IControllerActivator>(new SimpleInjectorControllerActivator(_container));
services.AddSingleton<IViewComponentActivator>(new SimpleInjectorViewComponentActivator(_container));
services.UseSimpleInjectorAspNetRequestScoping(_container);
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
SimpleInjectorConfig.InitializeContainer(app, _container);
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
_container.Verify();
app.UseMvc();
}
Run Code Online (Sandbox Code Playgroud)
我知道问题在于选项,但我不知道Simple Injector如何需要注册到容器的默认连接字符串.这可以传递给Simple Injector吗?或者我应该使用DbContextFactory
传递连接字符串UserDbContext
?
嗨,我正在使用Ep Plus和Web应用程序.我正在创建一个Excel文件,用户可以填写并上传回应用程序.当我输入带前导零的数字时,它们会被截断.
是否允许用户输入前导零?
嗨,我正在尝试获取用户角色并将其设置为我的应用程序中的cookie
我有以下代码可行
public ActionResult Index()
{
var user = User.Identity.Name; // set by 3rd party central login in manager
// key to check that we are in our environment with 3rd party login set up
if (ConfigurationManager.AppSettings["IsNGDC"] == "true")
{
// ActiveKey login
if (user.Contains("uid="))
{
var endIndex = user.IndexOf(",ou");
var userEmail = user.Substring(4, endIndex - 4);
user = userEmail;
}
SetAuthenticationCookie(user);
}
// view model is not needed I could just pass in a string
var viewModel = new …
Run Code Online (Sandbox Code Playgroud) 我有一个表,我正在进行逻辑删除.我有一个列Name
和一列Is_Active
.Name
是一个varchar
,Is_active
是一个bool
.
我无法使其Name
独特,因为会有多个具有相同名称的行.哪里Is_Active == False
.
我需要确保在任何时候,只有一个用于记录Name
其中Is_Active == True
.
有没有办法可以做到这一点?或者任何人都可以提出更好的方法吗?
c# ×3
.net-core ×1
asp.net-core ×1
azure ×1
bundle ×1
cookies ×1
epplus ×1
excel ×1
html ×1
javascript ×1
jquery ×1
serilog ×1
sql-server ×1