我试图通过在mvc应用程序中使用SignalR向所有客户端广播消息。我遇到的问题是当我使用此代码时
var context = GlobalHost.ConnectionManager.GetHubContext<NotificationHub>();
Run Code Online (Sandbox Code Playgroud)
上下文没有客户端,因此不会广播该消息。下面是我正在使用的代码的简化版本。我想念什么吗?谢谢
风景:
@using System.Web.UI.WebControls
@using MyApp.Models
@model MyApp.Models.MyModel
<form class="float_left" method="post" id="form" name="form">
<fieldset>
Username: <br/>
@Html.TextBoxFor(m => m.Username, new { Value = Model.Username })
<br/><br/>
<input id="btnButton" type="button" value="Subscribe"/>
<br/><br/>
<div id="notificationContainer"></div>
</fieldset>
</form>
@section scripts {
<script src="~/Scripts/jquery.signalR-2.2.0.min.js"></script>
<script src="~/signalr/hubs"></script>
<script>
$(function () {
var notification = $.connection.notificationHub;
notification.client.addNewMessageToPage = function (message) {
$('#notificationContainer').append('<strong>' + message + '</strong>');
};
$.connection.hub.start();
});
$("#btnButton").click(function () {
$.ajax({
url: "/Home/Subscribe",
data: $('#form').serialize(),
type: "POST"
});
}); …Run Code Online (Sandbox Code Playgroud) 我的目的是在调用该容器的 docker-compose 时能够将一些参数传递给 docker 容器。
就像是
docker-compose up -d myContainer myArg1=hallo myArg2=world
Run Code Online (Sandbox Code Playgroud)
我的 Docker 文件看起来像:
FROM mcr.microsoft.com/dotnet/core/runtime:2.2 AS final
WORKDIR /app
COPY Myproj/bin/Debug/netcoreapp2.1 .
ENTRYPOINT ["dotnet", "myproj.dll", myArg1, myArg2]
Run Code Online (Sandbox Code Playgroud)
docker-compose.yml 文件如下所示:
version: '3.4'
services:
myContainer:
image: ${DOCKER_REGISTRY-}myContainerImage
build:
context: ../..
dockerfile: MyProj/Dockerfile
Run Code Online (Sandbox Code Playgroud)
首先我想知道这是否可行,其次我想知道如何做到
我正在使用.net框架从jpg文件中读取exif元数据.问题是如何以可读形式(如字符串)转换PropertyItem.Value(即字节数组).
例如,使用此代码,我读取了图片的GPSAltitude值:
var pic = System.Drawing.Image.FromFile(@"c:\mypic.jpg");
var GPSAltitude = pic.GetPropertyItem(6);
Run Code Online (Sandbox Code Playgroud)
GPSAltitude.Value是一个像这样的字节数组:{75,2,0,0,1,0,0,0}.
我知道海拔高度是587 msl ..但是如何从该字节数组转到587?
我尝试用ASCIIencoding和其他一些编码来读它,但我得到类似"K\0\0\0\0\0"的东西.
任何的想法 ?谢谢