当我从 Visual Studio 运行 azure 函数时出现以下错误。
发生 ScriptHost 错误 [1/19/2018 6:40:52 AM] 函数“MyFunctionName”的侦听器无法启动。Microsoft.WindowsAzure.Storage:服务器遇到内部错误。请过一段时间再试。
当我通过运行func host start
命令从命令提示符运行时。我收到以下警告。然后它被卡住了
实例ID获取的主机锁租约
.
没有找到工作职能。尝试公开您的作业类和方法。如果您使用绑定扩展(例如 ServiceBus、Timers 等),请确保您已在启动代码(例如 config.UseServiceBus()、config.UseTimers() 等)中调用了扩展的注册方法.)
Azure 函数版本:azure-functions-core-tools@2.0.1-beta.22
我正在使用存储帐户 Blob 容器和队列。
我正在连接到开发存储帐户,我已经检查它是否已启动存储模拟器。
{
"IsEncrypted": false,
"Values": {
"ConnectionStrings:Default": "Server=.\\SQLEXPRESS; Database=TestDb; Trusted_Connection=True;",
"ConnectionStrings:BlobStorageAccount": "UseDevelopmentStorage=true",
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"AzureWebJobsDashboard": "UseDevelopmentStorage=true",
}
}
Run Code Online (Sandbox Code Playgroud)
供参考。
以前工作正常,但我在 Visual Studio 中收到了这条消息。
您的许可证已经过时,必须更新。检查更新的许可证以继续使用此产品
所以我只是删除了%localappdata%和%temp%,然后我尝试运行 Azure 函数,在此之后,我开始得到
函数的侦听器无法启动错误
那么它与我的 Visual Studio 订阅有关还是我错误地删除了任何必需的文件?或者这与其他事情有关?
我正在Asp.Net Core 3.1中开发API,我下面有一个POST方法(内容类型是application/JSON
),我故意将无效的JSON传递给响应,并且响应也非常清晰。但我的问题是我可以进行更改以返回响应吗
国家/地区 ID 为必填字段
对于这个特殊情况。请告诉我是否可以完成,否则,我也同意这个响应(因为这个响应首先检查内容类型是否是有效的 JSON 也是有效的)。
方法:
public ActionResult ValidateFields(ValidateFieldsRequest validateFieldsRequest)
{
Run Code Online (Sandbox Code Playgroud)
请求类:
public class ValidateFieldsRequest
{
//string currencyCode, int countryId, string fieldName, string fieldValue
[Required]
public string currencyCode { get; set; }
[Required]
[RegularExpression("^[1-9]\\d*$", ErrorMessage = "Invalid fieldName.")]
public int countryId { get; set; }
[Required]
[MinLength(1, ErrorMessage = "At least one field required")]
public List<Field> fields { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
要求:
{
"currencyCode": "RUB",
"countryId": ,
"fields": [{
"fieldName": "BIC or Bank …
Run Code Online (Sandbox Code Playgroud) 所以我写代码的时间不长,所以经验也不是很多,最近我在 replit.com 上遇到了一个问题,控制台会打印出:
error CS8803: Top-level statements must precede namespace and type declarations.
using System;
Run Code Online (Sandbox Code Playgroud)
有人能提出这个问题吗?这是我的代码,供任何想知道的人使用:
int English;
int Science;
int AverageCalc;
AverageCalc = Convert.ToInt32(Console.ReadLine());
class Program {
public static void Main (string[] args) {
Console.WriteLine("Write your math grades");
Math = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Write your english grades");
English = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Write your science grades");
Science = Convert.ToInt32(Console.ReadLine());
AverageCalc = (Math+English+Science/3);
}
}
if (AverageCalc > 80)
{
Console.WriteLine("You passed with A mark!");
}
else if (AverageCalc < 80)
{
Console.WriteLine("You passed …
Run Code Online (Sandbox Code Playgroud) 我git
在我的项目中使用.有时我需要与同事或不同的PC共享我修改后的更改,但我不想推动这些更改.他将接受我的代码并修改一些内容然后将推送该代码.现在我手动通过邮件给他发送文件或者用笔式驱动器发送文件.我希望通过这个来完成git
.我可以喜欢git commit
然后分享git push
吗?
验证无法正常运行.它始终显示此字段是必需的.即使我不碰这个领域.为什么?
<div class="form-group">
<label class="control-label col-sm-4">Description<span class="required"> * </span></label>
<div class="col-sm-8">
<input type="text" name="name" data-required="1" class="form-control" aria-required="true" aria-invalid="true" aria-describedby="name-error">
<span id="name-error" class="help-block help-block-error">This field is required.</span>
</div>
</div>
Run Code Online (Sandbox Code Playgroud) 我正在使用 Swagger 在 Asp.Net Core 应用程序中测试我的 API。我通过输入这样的令牌来发送请求Authorization: Bearer {token}
。但授权标头未在请求中发送。
Asp.Net Core 版本 3.1 和 Swashbuckle.AspNetCore 5.4.1
Startup.cs代码:
public class Startup
{
private const string _apiVersion = "v1";
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddJwtBearer(options =>
{
options.TokenValidationParameters = new TokenValidationParameters
{
ClockSkew = TimeSpan.FromMinutes(0),
ValidateIssuer = true, …
Run Code Online (Sandbox Code Playgroud) 我有一个 CSV 文件,我正在尝试解析它,但是在 int 数据类型列上出现以下错误。在文件中,我传递了该列的空白或空值。
[AutoMap(typeof(Test))]
[FileEntity("Test")]
public class TestFileEntity : BaseFileEntity
{
[CsvFileColumn(1)]
public int TestId { get; set; }
}
public IEnumerable<BaseFileEntity> Parse(Stream masterData, Type entityType, out IEnumerable<MasterDataFileParserError> errors)
{
var list = new List<BaseFileEntity>();
var errorList = new List<MasterDataFileParserError>();
try
{
using (var reader = new StreamReader(masterData))
{
var parser = new CsvReader(reader, new CsvHelper.Configuration.Configuration
{
HasHeaderRecord = true,
HeaderValidated = null,
MissingFieldFound = null
});
list.AddRange(parser.GetRecords(entityType).Cast<BaseFileEntity>());
}
}
catch (Exception ex)
{
if (ex.Data == null …
Run Code Online (Sandbox Code Playgroud) 我正在使用DevExtreme dxGrid
来显示和编辑用户的数据,我有一个查阅列来选择用户部门.网格中的数据显示正确,但是在我按下编辑按钮并弹出窗体显示查找字段后,显示部门的id值,而不是指定的值DisplayExpr
,但是当我单击下拉列表时,正确显示的值.
我在DevExpress网站上搜索了很多,并尝试了他们所说的关于数据源和JS之间类型不匹配的所有内容,但没有任何效果.
该CSHTML代码:
@(Html.DevExtreme().DataGrid().ID("gridContainer")
.DataSource(d => d.WebApi().Controller("UsersApi").Key("Id").LoadAction("GetUsers").UpdateAction("Put"))
.AllowColumnReordering(true)
.AllowColumnResizing(true)
.ColumnAutoWidth(true)
.ColumnChooser(c => c.Enabled(true))
.GroupPanel(groupPanel => groupPanel.Visible(true))
.OnToolbarPreparing("OnToolbarPreparing")
.OnEditorPreparing("OnEditorPreparing")
.Editing(e =>
{
e.AllowUpdating(true);
e.Mode(GridEditMode.Popup);
})
.Columns(c =>
{
c.Add().DataField("IsActive").Caption("Active").Width("100");
c.Add().DataField("UserName").Caption("Username").Width("120").AllowEditing(false);
c.Add().DataField("FullName").Caption("Full Name").Width("200");
c.Add().DataField("Email").Width("250");
c.Add().DataField("CreatedUtc")
.Caption("Created")
.DataType(GridColumnDataType.Date)
.CellTemplate(new JS("created_CellTemplate"))
.Visible(false)
.ShowInColumnChooser(true)
.AllowEditing(false)
.Width("80");
c.Add().DataField("CreatedBy").Caption("Created By").Visible(false).ShowInColumnChooser(true).AllowEditing(false).Width("120");
c.Add().DataField("LastAccessStr")
.Caption("Latest Access")
.CellTemplate(new JS("latestAccess_CellTemplate"))
.CalculateSortValue("LastAccessUtc")
.SortOrder(SortOrder.Desc)
.AllowEditing(false)
.Width("120");
c.Add().DataField("LastLoginStr")
.Caption("Latest Login")
.CellTemplate(new JS("latestLogin_CellTemplate"))
.CalculateSortValue("LastLoginUtc")
.AllowEditing(false).Visible(false).ShowInColumnChooser(true)
.Width("120");
c.Add().DataField("LastLoginIP").Caption("Latest Login IP").AllowEditing(false).Width("150");
c.Add().DataField("PhoneNumber").Caption("Phone").Width("150").Visible(false).ShowInColumnChooser(true);
c.Add().DataField("Role").Width("200");
c.Add().DataField("DepartmentId").Caption("Department").Width(200).Lookup(
lookup => lookup
.DataSource(d => …
Run Code Online (Sandbox Code Playgroud) 我想使用 EF 迁移在我的数据库中添加一些数据。事实是所有 Id 都是自动生成的。我找到了使用 EF Core 实现它的标准方法,如下所示
modelBuilder.Entity<TypeNote>()
.HasData(
new TypeNote { Id = 1, Name = "General" },
new TypeNote { Id = 2, Name = "E-mail" },
new TypeNote { Id = 3, Name = "Meeting" },
new TypeNote { Id = 4, Name = "Reminder" },
new TypeNote { Id = 5, Name = "Telephone" },
new TypeNote { Id = 6, Name = "Visit" }
);
Run Code Online (Sandbox Code Playgroud)
我的问题是我不想指定Id
,但似乎没有其他方法可以使用HasData
方法。
你知道另一种使用迁移在数据库中添加数据的方法吗?
c# ×7
asp.net-core ×3
.net-core ×2
azure ×2
.net-6.0 ×1
angular ×1
api ×1
csvhelper ×1
datagrid ×1
devexpress ×1
devextreme ×1
git ×1
html ×1
javascript ×1
metronic ×1
swagger ×1
swagger-ui ×1
swashbuckle ×1