我们遇到了SignalR的问题.我们有一个拍卖网站,可以通过信号灯进行实时出价.我们修复了浏览器的一些问题,一切似乎都运行良好.然后我们在我们的服务器上安装了新的遗物并注意到我们每分钟都在信号器连接,重新连接和中止上获得http错误代码400.这是一个截图:
根据新遗迹,SignalR连接和重新连接是网站最耗时的操作.
这是SignalR后端代码(我们使用sql server作为signalr backplane):
public class SignalRHub : Hub
{
public void BroadCastMessage(String msg)
{
var hubContext = GlobalHost.ConnectionManager.GetHubContext<SignalRHub>();
hubContext.Clients.All.receiveMessage(msg);
}
}
public partial class Startup
{
public void Configuration(IAppBuilder app)
{
string appString=string.Empty;
//Gets the connection string.
if (System.Configuration.ConfigurationSettings.AppSettings["SignaRScaleoutConn"] != null)
{
appString = System.Configuration.ConfigurationSettings.AppSettings["SignaRScaleoutConn"].ToString();
}
GlobalHost.DependencyResolver.UseSqlServer(appString);
GlobalHost.Configuration.ConnectionTimeout = TimeSpan.FromMinutes(15); //I added this timeout, but it is not required.
app.MapSignalR();
}
}
Run Code Online (Sandbox Code Playgroud)
javascript客户端看起来像这样,它很冗长,但大多数是jQuery来影响DOM,我把它包括在内以防万一内部可能有问题.
$(function () {
var chatProxy = $.connection.signalRHub;
$.connection.hub.start();
chatProxy.client.receiveMessage = function (msg) {
var all …Run Code Online (Sandbox Code Playgroud) 我对Identity有一个问题,我对它不是很熟悉.不久前,我开始了一个新项目,原本并不打算附加任何身份验证.但是,随着项目的发展,我们发现我们应该实施它.由于它最初没有这样设置,我创建了一个登录表单.
我找到了这个问题的答案并实现了它:
但它不起作用,我不知道为什么.
这是我的代码:
没什么好看的,这只是一个简单的形式.
@{
ViewBag.Title = "Login";
}
<div class="container">
<h2>Login</h2>
<br />
@using (Html.BeginForm("Login", "Main"))
{
<div class="row">
<div class="form-group col-xs-6">
@Html.Label("Username", htmlAttributes: new { @class = "control-label col-sm-3" })
<div class="col-sm-8">
@Html.TextBox("username", null, new { @class = "form-control" })
@*Html.ValidationMessageFor(model => model.EnrollmentOption, "", new { @class = "text-danger" })*@
</div>
</div>
<div class="form-group col-xs-6">
</div>
</div>
<div class="row">
<div class="form-group col-xs-6">
@Html.Label("Password", htmlAttributes: new { @class = "control-label col-sm-3" })
<div class="col-sm-8">
@Html.Password("password", …Run Code Online (Sandbox Code Playgroud) 所以aws-lambda-tools-defaults.json我的项目有一个非常简单的:
{
"profile": "default",
"region": "us-east-2",
"configuration": "Release",
"framework": "netcoreapp3.1",
"function-runtime": "dotnetcore3.1",
"function-memory-size": 256,
"function-timeout": 30,
"function-handler": "LaCarte.RestaurantAdmin.EventHandlers::LaCarte.RestaurantAdmin.EventHandlers.Function::FunctionHandler"
}
Run Code Online (Sandbox Code Playgroud)
它有效,我可以在本地测试我的 lambda 代码,这很棒。但我希望能够测试多个 lambda,而不仅仅是一个。有其他人知道如何更改 JSON 以便我可以在模拟工具中运行多个 lambda 表达式吗?
提前致谢,
我有一个关于asp.net核心电子邮件发送的问题.
所以我有这个代码:
private void SendEmailLocalSMTP(string email, string subject, string message)
{
MimeMessage mailMsg = new MimeMessage();
//TESTING ENVIRONMENT ONLY!!!
mailMsg.To.Add(new MailboxAddress("myMail@gmail.com", "cjimenezber@gmail.com"));
// From
mailMsg.From.Add(new MailboxAddress("noreply@app.com", "Facturacion"));
// Subject and multipart/alternative Body
mailMsg.Subject = subject;
string html = message;
System.Net.NetworkCredential credentials = new System.Net.NetworkCredential("myMail@gmail.com", "myPassword");
// Init SmtpClient and send
using (var client = new SmtpClient())
{
client.Connect("smtp.gmail.com", 587, SecureSocketOptions.StartTls);
client.AuthenticationMechanisms.Remove("XOAUTH2");
client.Authenticate(credentials);
client.Send(mailMsg);
client.Disconnect(true);
}
}
Run Code Online (Sandbox Code Playgroud)
从我在其他帖子中发现的有些相关,这应该足以使用MailKit发送它,但它不能正常工作.我收到以下异常,我不知道如何从这里开始.
这是例外:
我已经看到了这个问题,但我没有太多意义:如何使用MailKit发送电子邮件?
任何帮助都非常感谢,谢谢.
所以我试图注入一个通用存储库,它接收实体类型和实体使用的键类型作为通用类型。
声明如下所示:
public class GenericRepository<KeyType, T> : BaseRepository<T, NpgsqlConnection>, IGenericRepository<KeyType, T>
where T : class
where KeyType : struct
Run Code Online (Sandbox Code Playgroud)
所以我尝试像这样注入它们:
services.AddTransient(typeof(IGenericRepository<>), typeof(GenericRepository<>));
Run Code Online (Sandbox Code Playgroud)
这适用于只有一种泛型类型但不适用于两种类型的情况。我收到以下错误:
使用泛型类型 'GenericRepository<KeyType, T>' 需要 2 个类型参数
有谁知道如何解决这个问题?
我知道我可以为每个人都开设课程,但我想像这样注入它:
public class RestaurantTypesService : IRestaurantTypesService
{
private readonly IGenericRepository<long, RestaurantType> _restaurantTypeRepository;
public RestaurantTypesService(IGenericRepository<long, RestaurantType> repository)
{
_restaurantTypeRepository = repository;
}
}
Run Code Online (Sandbox Code Playgroud) 所以我一直在学习一些.net核心,我正在用它构建一个API.通常我会使用角度并在那里发送请求.
我有以下角度片段:
//The data I need to send.
$scope.PersonalInfo = {
firstName: '',
lastName: '',
companyName: '',
email: '',
password: '',
confirmPassword: '',
imageLink: ''
};
Run Code Online (Sandbox Code Playgroud)
然后是相同数据的后端模型:
public class UserProfileModel
{
public string userID { get; set; }
public string firstName { get; set; }
public string lastName { get; set; }
public string companyName { get; set; }
public string email { get; set; }
public string password { get; set; }
public string confirmPassword { get; set; } …Run Code Online (Sandbox Code Playgroud) c# ×3
asp.net ×2
asp.net-core ×2
asp.net-mvc ×2
.net-core ×1
angularjs ×1
aws-lambda ×1
email ×1
gmail ×1
identity ×1
javascript ×1
mailkit ×1
signalr ×1
signalr-hub ×1