我正在尝试在ASP.NET Core中使用这个库:https://github.com/infusion/jQuery-webcam来获取从网络摄像头拍摄的照片.
在这个例子中,MVC Capture网络摄像头图像,将图像的文件路径保存到数据库,这是怎么回事:
$(document).ready(function () {
$("#Camera").webcam({
width: 320,
height: 240,
mode: "save",
swffile: "@Url.Content("~/Scripts/jscam.swf")",
onTick: function () { },
onSave: function () {
},
onCapture: function () {
webcam.save("@Url.Action("Capture", "TrapActivity", new { id = @Model.Id , pid = @Model.PersonId})");
},
debug: function () { },
onLoad: function () { }
});
});
Run Code Online (Sandbox Code Playgroud)
调用的Controller方法Capture从此行的View中调用:webcam.save("@Url.Action("Capture", "TrapActivity", new { id = @Model.Id , pid = @Model.PersonId})");
public ActionResult Capture(string ID)
{
var …Run Code Online (Sandbox Code Playgroud) 我正在尝试在ASP.NET Core Web API上自定义swagger UI。
我想要这样的用户界面:
我正在关注这些教程:
这是Startup.cs配置:
// Add the detail information for the API.
services.ConfigureSwaggerGen(options =>
{
// Determine base path for the application.
var basePath = _env.WebRootPath;
// Complete path
var xmlPath = Path.Combine(basePath, "myapi.xml");
// Set the comments path for the swagger json and ui.
options.IncludeXmlComments(xmlPath);
});
app.UseStaticFiles();
// Enable middleware to serve generated Swagger as a JSON endpoint
app.UseSwagger();
// Enable middleware to serve swagger-ui assets (HTML, JS, CSS etc.)
app.UseSwaggerUI(c =>
{ …Run Code Online (Sandbox Code Playgroud) visual-studio webdeploy asp.net-web-api .net-core asp.net-core
我需要检查我的JwtSecurityToken是否过期。
我正在使用System.IdentityModel.Tokens.Jwt图书馆。
当创建一个JwtSecurityToken这样的:
var token = new JwtSecurityToken(
issuer: token_issuer,
audience: token_audience,
claims: claims,
expires: DateTime.Now.AddMinutes(15),
signingCredentials: creds
);
Run Code Online (Sandbox Code Playgroud)
并检查它的生命周期,我比当前时间晚了2 小时。
我以这种方式检查寿命(仅用于测试目的):
var lifeTime = new JwtSecurityTokenHandler().ReadToken(token).ValidTo;
Run Code Online (Sandbox Code Playgroud)
我的验证方法:
private static bool ValidateToken(string token)
{
try
{
TokenValidationParameters validationParameters = new TokenValidationParameters
{
IssuerSigningKey = new SymmetricSecurityKey(token_salt),
ValidAudience = token_audience,
ValidIssuer = token_issuer,
RequireExpirationTime = true
};
var lifeTime = new JwtSecurityTokenHandler().ReadToken(token).ValidTo;
ClaimsPrincipal principal = new JwtSecurityTokenHandler().ValidateToken(token_last, validationParameters, out SecurityToken validatedToken);
return true; …Run Code Online (Sandbox Code Playgroud) 我正在尝试将Xamarin.Android中的Java类转换为C#。
原始的Java类具有以下内容:
private native boolean OpenDeviceCtx(Object obj);
public native boolean CloseDevice();
public native boolean GetDiodesStatus(byte[] bArr);
public native boolean GetFrame(byte[] bArr);
public native boolean GetImage(int i, byte[] bArr);
public native boolean GetImage2(int i, byte[] bArr);
public native boolean GetImageByVariableDose(int i, byte[] bArr);
public native boolean GetImageSize();
public native boolean GetInterfaces(byte[] bArr);
public native String GetVersionInfo();
public native boolean IsFingerPresent();
public native boolean OpenDevice();
public native boolean OpenDeviceOnInterface(int i);
public native boolean Restore7Bytes(byte[] bArr);
public native boolean RestoreSecret7Bytes(byte[] bArr, byte[] bArr2); …Run Code Online (Sandbox Code Playgroud) 在令牌验证中,我检查了令牌的生命周期,它是13:07:10。当我运行验证时,时间是13:12,验证成功。为什么?
大约13:15时,我再次运行验证,正如预期的那样,它抛出了异常。
令牌是否有最短过期时间?
创建令牌:
var token = new JwtSecurityToken(
issuer: token_issuer,
audience: token_audience,
claims: claims,
expires: DateTime.Now.AddSeconds(5),
signingCredentials: creds
);
Run Code Online (Sandbox Code Playgroud)
验证令牌:
private static bool ValidateToken(string token)
{
try
{
TokenValidationParameters validationParameters = new TokenValidationParameters
{
IssuerSigningKey = new SymmetricSecurityKey(token_salt),
ValidAudience = token_audience,
ValidIssuer = token_issuer,
RequireExpirationTime = true
};
ClaimsPrincipal principal = new JwtSecurityTokenHandler().ValidateToken(token_last, validationParameters, out SecurityToken validatedToken);
return true;
}
catch(SecurityTokenExpiredException ex)
{
}
return false;
}
Run Code Online (Sandbox Code Playgroud) 我需要统计一家公司的所有考试,如果该公司不存在于考试表中,则返回 0。
在我的公司表中,我有 3 家公司。这是我的查询:
SELECT c.name, ISNULL(COUNT(e.ID), 0)
FROM Exam e
INNER JOIN Company c ON c.ID = e.COMPANY_ID
GROUP BY c.name
Run Code Online (Sandbox Code Playgroud)
它返回 2 行,但我想显示检查表中没有任何记录的第三家公司。
我怎样才能做到这一点?
我正在尝试在 Mapbox GL JS 中的地理编码器结果后添加可拖动标记并设置事件dragend。我需要这个,以便用户可以将标记拖动到他想要的确切位置。
这是我遵循的教程:在地理编码器结果后设置点
通过本教程,我可以使用可拖动选项添加标记,但我不知道如何将事件添加dragend到标记。
var geocoder = new MapboxGeocoder({
accessToken: Mapboxgl.accessToken,
language: 'pt-BR',
marker: {
draggable: true,
color: 'red'
},
placeholder: 'Pesquise por cidade, rua, bairro ou CEP',
mapboxgl: Mapboxgl
});
Run Code Online (Sandbox Code Playgroud)
我尝试创建一个标记并将其设置为标记属性,但没有成功:
const marker = new Mapboxgl.Marker({
draggable: true
});
marker.on('dragend', () => {
console.log(marker.getLngLat());
});
var geocoder = new MapboxGeocoder({
accessToken: Mapboxgl.accessToken,
language: 'pt-BR',
marker: marker,
placeholder: 'Pesquise por cidade, rua, bairro ou CEP',
mapboxgl: Mapboxgl
});
Run Code Online (Sandbox Code Playgroud)
我有什么想法可以解决这个问题吗?
我知道还有其他问题,但我想要更好的解释.
我想用我的Model.List显示一个表,在POST之后我仍然需要访问该列表.今天没有发生这种情况.
这是我的cshtml:
@foreach (var student in Model.ListSchedulingDetails)
{
<tr>
<td width="150">
@Html.DisplayFor(modelItem => student.SchedulingDate)
</td>
<td width="250">
@Html.DisplayFor(modelItem => student.TeacherName)
</td>
<td width="250">
@Html.DisplayFor(modelItem => student.StudentName)
</td>
<td width="150">
@Html.DisplayFor(modelItem => student.SchedulingHour)
</td>
<td width="250">
@Html.DisplayFor(modelItem => student.SchedulingObservation)
</td>
</tr>
}
Run Code Online (Sandbox Code Playgroud)
POST后,我的Model.ListSchedulingDetails为null.发生了什么?
c# ×6
asp.net-core ×3
asp.net ×2
jwt ×2
token ×2
.net-core ×1
android ×1
angular ×1
asp.net-mvc ×1
java ×1
mapbox-gl-js ×1
mono ×1
sql ×1
swagger ×1
swagger-ui ×1
webdeploy ×1