我想创建一系列的html页面(egdiv有员工详细信息列表).当用户点击div时,我想导航到另一个页面.请看看这个.
问题是当我第一次加载页面时,div的click事件被触发了.如何避免在页面加载事件期间被触发的不必要的点击事件?
<div data-bind="click: clickMe('ok1')">
<h1>Emplyee details</h1>
<p>This is test</p>
</div>
<div data-bind="click: clickMe('ok2')">
<h1>Emplyee details</h1>
<p>This is test</p>
</div>
var ViewModel = function(){
var self = this;
self.clickMe = function(url){
//This function is automatically getting called
//when page loads.
alert(url);
}
}
ko.applyBindings(new ViewModel());
Run Code Online (Sandbox Code Playgroud)
问候,Hemant
我使用owin中间件保护我的Web API时遇到问题.
我安装了下面的包
Install-Package Microsoft.Owin.Cors -Version 2.1.0
Run Code Online (Sandbox Code Playgroud)
以下是ConfigureAuth.cs代码.
public void ConfigureAuth(IAppBuilder app)
{
//...
app.UseOAuthBearerTokens(OAuthOptions);
///Install-Package Microsoft.Owin.Cors -Version 2.1.0
app.UseCors(Microsoft.Owin.Cors.CorsOptions.AllowAll);
}
Run Code Online (Sandbox Code Playgroud)
我在一个链接上托管了这个WebApi项目,比如http://webaip.azurewebsites.net
我试图从另一个站点访问上述API的控制器方法,比如说,http: //mysite.azurewebsites.net上面的代码我可以调用所有不安全的API方法.(未使用Authorize属性修饰)通过javascript我无法调用/ Token进行身份验证.以下是我的javascript代码.
function LogIn() {
var loginData = {
grant_type: 'password',
username: 'username',
password: 'password',
};
$.ajax({
type: 'POST',
url: 'http://webaip.azurewebsites.net/Token/',
data: loginData
}).done(function (data) {
alert('logged in');
alert(data);
}).fail(function (data) {
alert('login problem')
}).error(function (data) {
alert('error invoking API');
});
return false;
}
Run Code Online (Sandbox Code Playgroud)
我收到了以下错误
XMLHttpRequest cannot load http://webaip.azurewebsites.net/Token/. No 'Access-Control-Allow-Origin' header is present on …Run Code Online (Sandbox Code Playgroud) 我是Bootstrap 3.0的新手.任何人都能告诉我下面代码中"navbar-brand"类的重要性是什么?
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>@ViewBag.Title - My ASP.NET MVC Application</title>
<link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link href="~/Content/bootstrap.css" rel="stylesheet" />
<link href="~/Content/bootstrap-theme.css" rel="stylesheet" />
@Scripts.Render("~/bundles/modernizr")
</head>
<body>
<nav class="navbar-wrapper navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
<span class="sr-only">Toggle Navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand">Vacation Rentals</a>
</div>
</div>
</nav>
<div id="body" class="container">
@RenderBody()
</div>
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/jqueryui")
@Scripts.Render("~/Scripts/bootstrap.js")
@RenderSection("scripts", required: false)
</body> …Run Code Online (Sandbox Code Playgroud) 我试图了解IdentityServer3以及与之相关的不同术语,以保护我的Web API.有人可以通过一些很好的例子来解释IdentityServer 中Scope的重要性.
我找到了这个链接,但想法不明确.
提前致谢!
我正在尝试为几个名为' Employee'和' 的表实现DbContext.Department员工和部门之间的关系是多对一的.即部门可以有很多员工.
下面是我设计的EntityFramework类(CodeFirst方法)
[Table("Employee")]
public class Employee
{
[DatabaseGenerated(System.ComponentModel.DataAnnotations.Schema.DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
[Column("Name")]
public string Name { get; set; }
[Column("Department_ID")]
public int Department_ID { get; set; }
public virtual Department Department { get; set; }
}
[Table("Department")]
public class Department
{
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int ID { get; set; }
[Column("Name")]
public string Name { get; set; }
public virtual ICollection<Employee> Employees { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
在添加员工记录时,我得到的是异常
"Invalid column name 'Department_ID1'." …Run Code Online (Sandbox Code Playgroud) Azure Service Bus Queue我正在尝试从我的应用程序访问Windows Service。我正在关注这个样本。
我想Azure Service Bus使用Azure Service Principal 下面是我已实施的步骤来保护它
pc-shutdown-producer代表Azure Ad
我的应用程序Windows Serviceservice bus namespace名为shutdowncomputer Access control (IAM),我添加了Role Assignment以下值
Azure Service Bus Data Ownerpc-shutdown-producer据我所知,上述配置将让pc-shutdown-producer应用程序管理 servicebus 命名空间中的所有资源。4. 除此之外,我还提供了pc-shutdown-producer访问服务总线命名空间的委托 API 权限。
下面是我的 C# 代码。
public async Task Init()
{
string authority = $"https://login.windows.net/{TenantId}";
ITokenProvider tokenProvider = TokenProvider.CreateAzureActiveDirectoryTokenProvider(AuthenticationCallback, authority);
var …Run Code Online (Sandbox Code Playgroud) servicebus azureservicebus azure-servicebus-queues azure-servicebus-topics azure-rbac
我是CSS和Bootstrap 3.0的新手.下面是我可以在很多地方找到的代码,现在我可以毫无问题地编写它.但我真的不知道事情是如何在幕后工作的.
<div class="navbar navbar-static-top navbar-inverse" role="navigation">
<a class="navbar-brand">Company</a>
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".top-nav">
<span class="sr-only">Toggle Navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="collapse navbar-collapse top-nav">
<ul class="nav navbar-nav">
<li class="active"><a href="#">Home</a></li>
<li><a href="#">News</a></li>
<li><a href="#">About Us</a></li>
<li><a href="#">Contact</a></li>
</ul>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
上面的代码将为我提供动态UI.有人可以回答我的下面的问题
问候,Hemant
在我的MVC4应用程序中,我参考了我的EF模型组件.一切都很好.突然间,我开始收到以下错误消息.
The default DbConfiguration instance was used by the Entity Framework before the 'EFConfiguration' type was discovered. An instance of 'EFConfiguration' must be set at application start before using any Entity Framework features or must be registered in the application's config file. See http://go.microsoft.com/fwlink/?LinkId=260883 for more information.
Run Code Online (Sandbox Code Playgroud)
我正在使用EF 6.任何想法可能是什么原因?我仔细检查数据库并更新并与EF dll同步.
更新:当我尝试实例化Context对象时,我收到此错误
mEntities context = new Entities();
Run Code Online (Sandbox Code Playgroud)
谢谢
我们从TFS下载了一个项目,在恢复Nuget包后,我们得到以下错误:
Error 5 The "ValidatePackageReferences" task could not be loaded from the assembly projectPath\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.Tasks.dll. Could not load file or assembly 'file:///projectPath\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.Tasks.dll' or one of its dependencies. The system cannot find the file specified. Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask. projectName
Run Code Online (Sandbox Code Playgroud)
我们没有在任何地方使用过Task.它似乎在内部使用.任何指针如何摆脱这个错误?由于NuGet包的版本错误,它看起来很像.但不确定是什么原因.
我们正在使用VS 2013 Update 5版本.
我已经使用此docker 映像在我的开发计算机上设置了 RabbitMQ 服务器。
\n\n我使用下面的命令来设置我的容器
\n\ndocker run -d --name my-rabbit -p 5672:15672 rabbitmq:3-management
以下是 docker ps 命令输出
\n\nCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES\na40704b7f3a4 rabbitmq:3-management "docker-entrypoint.s\xe2\x80\xa6" 13 minutes ago Up 12 minutes 4369/tcp, 5671-5672/tcp, 15671/tcp, 25672/tcp, 0.0.0.0:5672->15672/tcp my-rabbit
管理控制台可通过http://localhost:5672访问,我可以使用默认用户名和密码( guest/guest )登录
\n\n下面是我的.Net Core 代码
\n\npublic RabbitMQMnager()\n {\n var factory = new ConnectionFactory();\n factory.Port = 5672;\n Uri uri = new Uri("amqp://guest:guest@localhost:5672/");\n\n var connection = factory.CreateConnection();\n\n //Below are values of different connection …Run Code Online (Sandbox Code Playgroud) .net-core ×1
azure-rbac ×1
build ×1
c# ×1
c#-4.0 ×1
cors ×1
css3 ×1
docker ×1
javascript ×1
knockout.js ×1
msbuild ×1
msbuild-task ×1
oauth-2.0 ×1
rabbitmq ×1
servicebus ×1