我有两台服务器
我已经把它全部设置好了,它适用于Chrome中的longpolling.(1)使用Firefox并导航到时要求输入用户名和密码https://localhost:44301/signalr/hubs.
(1)使用Windows身份验证.我试图通过执行以下操作来避免身份验证web.config:
<location path="signalr">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>
Run Code Online (Sandbox Code Playgroud)
但SignalR不是路径,因为它是自动生成的.我也尝试这样做以暴露集线器,但无济于事:
<location path="~/Hubs">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>
Run Code Online (Sandbox Code Playgroud)
任何人都可以帮我找到一种方法从https:// localhost:12321/signalr /*删除身份验证?(这包括所有信号器/协商调用++)
我无法使用以下内容,其中array是CustomerContract的数组:
Mapper.Map<IEnumerable<Customer>>(array);
Mapper.Map<IEnumerable<CustomerContract>, IEnumerable<Customer>>(array);
Mapper.Map<Array, List<Customer>>(array);
Run Code Online (Sandbox Code Playgroud)
在我看来,第一个例子应该足够了,但我无法工作.我已经阅读了automapper的配置wiki(https://github.com/AutoMapper/AutoMapper/wiki/Configuration),但我不明白为什么这是必要的.Automapper所需的一切都在命令中定义.它是哪种类型(对象和它是一个列表),以及我希望它映射到哪个对象.
我只是不了解Automapper的核心概念?
我的例外听起来像这样:
缺少类型映射配置或不支持的映射.
映射类型:\ r \nCustomerContract - > Customer\r \nStimline.Xplorer.Repository.CustomerService.CustomerContract - > Stimline.Xplorer.BusinessObjects.Customer
目标路径:List`1 [0]
源值:Stimline.Xplorer.Repository.CustomerService .CustomerContract
我一直在网上搜索,发现许多奇怪的答案,我几乎尝试了所有这些.我的问题是这个.我的登录页面包含:
FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, userName, DateTime.Now, DateTime.Now.AddMinutes(min), persistCookie, userid.ToString());
string encTicket = FormsAuthentication.Encrypt(ticket);
HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, encTicket);
cookie.Expires = ticket.Expiration;
Response.Cookies.Add(cookie);
FormsAuthentication.RedirectFromLoginPage(userName, persistCookie);
Run Code Online (Sandbox Code Playgroud)
现在min值是基于每个用户的,可以单独设置,persistCookie也是如此.
根据我的理解,此代码应该导致覆盖web.config中的默认值的可能性.这应该是30分钟.
<authentication mode="Forms">
<forms loginUrl="~/Default/default.aspx" defaultUrl="~/User/UserMain.aspx"/>
</authentication>
Run Code Online (Sandbox Code Playgroud)
min当前设置为120,并且persistCookie设置为太真.当我登录时,我会在30分钟时超时.(不是会话,所以设置了某个到期日期,因为如果没有设置cookie应该是基于会话的,我也不会得到120分钟,这是一种交易在这里)
我的问题是,为了简化它,我如何将值'min'作为cookie的到期日期?
这可能会变成一件简单的事情,但我现在完全陷入困境,所以任何帮助都会受到影响.
编辑:我将登录逻辑更改为:
FormsAuthenticationTicket fat = new FormsAuthenticationTicket(1, userName, DateTime.Now, DateTime.Now.AddMinutes(min), persistCookie, userid.ToString());
string encTicket = FormsAuthentication.Encrypt(fat);
Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName, encTicket) { Expires = fat.Expiration });
Response.Redirect(FormsAuthentication.GetRedirectUrl(userName, false));
Run Code Online (Sandbox Code Playgroud)
现在它有效.但我似乎无法弄清楚为什么这会起作用,而不是前一个.故障单创建是一样的,唯一的区别是我在创建HttpCookie时添加了HttpCookie的Expires属性,而不是在创建对象之后.
如果有人有一个很好的解释我都是耳朵!:)
在C#中,我会将许多处理程序挂钩到这样的事件:
event += firstEventHandler;
event += secondEventHandler;
Run Code Online (Sandbox Code Playgroud)
但是我们用SignalR写的JavaScript:
$.connection.someHubName.client.someEventName = function (item) {
console.log("someMessage", item);
};
Run Code Online (Sandbox Code Playgroud)
我创建了一个看起来像这样的包装器:
var signalRClient = {
start: function (callback) {
$.connection.hub.url = ajaxHttp + "/signalr";
$.connection.hub.logging = true;
if ($.connection.hub && $.connection.hub.state === $.signalR.connectionState.disconnected) {
$.connection.hub.start({ jsonp: true, withCredentials: true, transport: ['webSockets', 'longPolling'] }).done(callback);
} else {
callback();
}
},
connection: $.connection
}
Run Code Online (Sandbox Code Playgroud)
我可以这样打电话:
signalRClient.connection.somehub.client.someEvent = function (item) {
console.log("someMessage", item);
};
signalRClient.start(function () {
signalRClient.connection.somehub.server.subscribe(someId);
});
Run Code Online (Sandbox Code Playgroud)
但是如果我在多个视图中运行signalRClient(在同一个渲染页面上),它只能将一个函数分配给一个事件.我希望能够为一个事件分配许多功能.
我读过: 连接到信号器集线器和SignalR客户端有多个连接 ++
但我不认为为此目的创建许多连接到同一个集线器是个好主意.我还试图避免在布局中创建我的SignalR代码并使所有视图依赖于此.
有没有一个简单的解决方案,以便我可以挂钩许多事件处理程序 …
我有以下由 Hangfire 执行的代码(没有 HttpContext),当我在本地运行时运行完美:
class FakeController : ControllerBase
{
protected override void ExecuteCore() { }
public static string RenderViewToString(string controllerName, string viewName, object viewData)
{
using (var writer = new StringWriter())
{
var routeData = new RouteData();
routeData.Values.Add("controller", controllerName);
var fakeControllerContext = new ControllerContext(
new HttpContextWrapper(
new HttpContext(new HttpRequest(null, "http://nopage.no", null)
, new HttpResponse(null))
),
routeData,
new FakeController()
);
var razorViewEngine = new RazorViewEngine();
var razorViewResult = razorViewEngine.FindView(fakeControllerContext, viewName, "", false);
var viewContext = new ViewContext(fakeControllerContext, razorViewResult.View, new ViewDataDictionary(viewData), new …Run Code Online (Sandbox Code Playgroud) 我有一个看起来像这样的观点:
@model Wellbore
@(Html.Kendo().Grid<WellboreSection>()
.Name("wellboresectiongrid")
.Columns(columns =>
{
columns.Bound(p => p.Name);
columns.Bound(p => p.Lenght);
columns.Bound(p => p.SectionNumber);
columns.Bound(p => p.Volume);
columns.Bound(p => p.HoleDiameter);
columns.Command(command =>
{
command.Edit();
command.Destroy();
}).Width(240);
})
.ToolBar(toolbar => toolbar.Create())
.Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("WellboreSectionPopupTemplate"))
.Sortable()
.Scrollable()
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(10)
.Events(events => events.Error("KendoGrid.ErrorHandler"))
.Model(model => model.Id(p => p.Id))
.Create(create => create.Action("WellboreSection_Create", "WellboreSection",
new RouteValueDictionary(new Dictionary<string, object>() { { "wellboreId", Model.Id } })))
.Read(read => read.Action("WellboreSection_Read", "WellboreSection",
new RouteValueDictionary(new Dictionary<string, object>() { { "wellboreId", Model.Id } })))
.Update(update …Run Code Online (Sandbox Code Playgroud) 我意识到这应该很容易,而且我已经看到了我复制的关于pluralsight的教程。我仍然无法产生任何好的结果。我正在尝试在 SVG 元素中绘制文本。
\n\nSVG 元素定义如下:
\n\nSVG = d3.select("#wellguideDiagram")\n .append("svg")\n .attr({\n width: width + (padding * 2),\n height: height + (padding * 2)\n });\nRun Code Online (Sandbox Code Playgroud)\n\n然后我只需测试我是否可以实际编写一个文本元素:
\n\nSVG.append("text").text("wr\xc3\xa6\xc3\xa6\xc3\xa6\xc3\xa6\xc3\xa6\xc3\xa6\xc3\xa6\xc3\xa6\xc3\xa6\xc3\xa6\xc3\xa6\xc3\xa6\xc3\xa6\xc3\xa6\xc3\xa6\xc3\xa6\xc3\xa6\xc3\xa6\xc3\xa6\xc3\xa6l").attr({\n y: function (d) { return 250; },\n x: function () { return diagramWidth + 30 + (padding * 2); },\n fill: "red",\n "font-size": "15px",\n dy: ".35em"\n});\nRun Code Online (Sandbox Code Playgroud)\n\n我有一个包含以下内容的 JSON:
\n\nvar limits = {\n depthdefinition: {\n elements: [\n {\n depth: 3,\n value: "oter"\n },\n {\n depth: 30,\n value: "portugeese warship"\n },\n …Run Code Online (Sandbox Code Playgroud) c# ×5
javascript ×2
signalr ×2
asp.net ×1
automapper-3 ×1
cookies ×1
cors ×1
d3.js ×1
kendo-grid ×1
telerik ×1
web-config ×1