我有一个相当简单的网站,我正在使用ASP.NET Core.我从命令行运行应用程序,网站返回静态文件,但当我尝试发出应由MVC处理的请求时,我一直收到500错误.我怎么看错误是什么?无论错误是显示在浏览器上还是记录到控制台都没关系,我只是想知道错误是什么.
我有一堆字符串和pfx证书,我想存储在Azure Key保险库中,只允许用户/应用程序获取它们.将字符串存储为Secret并不难,但是如何以可以检索它的方式序列化证书并在C#中反序列化为X509Certificate2对象?
我试着将它存储为密钥.这是Azure powershell代码
$securepfxpwd = ConvertTo-SecureString -String 'superSecurePassword' -AsPlainText -Force
$key = Add-AzureKeyVaultKey -VaultName 'UltraVault' -Name 'MyCertificate' -KeyFilePath 'D:\Certificates\BlaBla.pfx' -KeyFilePassword $securepfxpwd
Run Code Online (Sandbox Code Playgroud)
但是当我试图用GetKeyAsync方法获取它时,我无法使用它.
当我从 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 订阅有关还是我错误地删除了任何必需的文件?或者这与其他事情有关?
我有一个使用AspNetCore.Authentication.Cookies的基于cookie身份验证的核心项目,但我似乎无法让用户进行身份验证.我已经阅读了类似的线程,但提供的解决方案似乎都没有用.
[HttpPost]
public async Task<IActionResult> CookieAuth(ITwitterCredentials userCreds)
{
var claims = new[] {
new Claim("AccessToken" , userCreds.AccessToken),
new Claim("AccessTokenSecret", userCreds.AccessTokenSecret)
};
var principal = new ClaimsPrincipal(new ClaimsIdentity(claims, "CookieAuthentication"));
await HttpContext.Authentication.SignInAsync("CookieAuthentication", principal);
return Ok();
}
Run Code Online (Sandbox Code Playgroud)
和startup.cs配置方法
app.UseCookieAuthentication(new CookieAuthenticationOptions()
{
AuthenticationScheme = "CookieAuthentication",
LoginPath = new PathString("/"),
AccessDeniedPath = new PathString("/"),
AutomaticAuthenticate = true,
AutomaticChallenge = true
});
Run Code Online (Sandbox Code Playgroud)
用户似乎没有进行身份验证,因为HttpContext.User.Identity.IsAuthenticated始终返回false.
知道为什么这可能不起作用吗?
我正在尝试使用Mac OSX上单独的类库中的视图运行项目,如下文所述
https://blogs.msdn.microsoft.com/webdev/2018/03/01/asp-net-core-2-1-razor-ui-in-class-libraries/
问题是我无法在Mac OS上使用Visual Studio Community 7.4构建类库项目.
项目使用命令行(donet build)构建没有问题,但是当我尝试使用Visual Studio构建它时,它会抛出两个错误:
/usr/local/share/dotnet/sdk/NuGetFallbackFolder/microsoft.aspnetcore.razor.design/2.1.0-preview1-final/build/netstandard2.0/Microsoft.AspNetCore.Razor.Design.Compilation.targets(10,10): Error MSB4064: The "SharedCompilationId" parameter is not supported by the "Csc" task. Verify the parameter exists on the task, and it is a settable public instance property. (MSB4064)
/usr/local/share/dotnet/sdk/NuGetFallbackFolder/microsoft.aspnetcore.razor.design/2.1.0-preview1-final/build/netstandard2.0/Microsoft.AspNetCore.Razor.Design.Compilation.targets(5,5): Error MSB4063: The "Csc" task could not be initialized with its input parameters. (MSB4063)
当我将RazorCompileOnBuild更改为false或从Content Build项目中删除内容时,编译没有错误.
我正在开发一个(.net core 2.0)控制台应用程序,现在我需要生成一个图表(它将包含 X/Y 轴上给定值的 2 行)并将其保存为图像(png、jpg)。我读过一些关于引用 Forms 程序集以便能够使用 .net 图表的想法,但我什至无法在此 VS.Net Core 2.0 控制台应用程序中找到 Assemblies 选项卡。有人知道一个工具或任何可以让我创建图表然后将其保存为图像的工具吗?
我正在创建一个可以在.Net Core 1.2,.Net Core 2.0和.NET Framework 4.6+之间共享的应用程序框架。因此,我将项目的目标框架选择为.NET Standard。在我的框架项目中,我具有用于发送文本消息或电子邮件的工厂类。在应用程序启动时,每个应用程序都将带有支持服务的工厂配置为带有DI框架的单例实例。
public class MyFactory : IMyFactory
{
private ILogger _logger;
private IDictionary<string,IMyService> _container = new Dictionary<string,IMyService>();
// this method is called on application startup to configure supported services
public void Configure(string[] keys, ILogger logger)
{
foreach(var key in keys)
{
if(key == "text")
{
container.Add(key,new TextMessageService());
}
if(key == "email")
{
container.Add(key,new EmailService());
}
}
}
//application call this method to send message
public bool SendMessage(string key, string message)
{
// we don't …Run Code Online (Sandbox Code Playgroud) 我使用ASP.NET核心标识(基于优秀的快速入门)与IdentityServer4一起使用ASP.NET核心应用程序. http://docs.identityserver.io/en/release/quickstarts/6_aspnet_identity.html 在演练博客中,他们谈到导航到localhost:5000/Account/Register以在Identity db中创建新用户.当我导航到该网址时,我会看到一个白页.此外,我没有Register.cshmtl页面或Register路由或其中包含术语Register的任何内容.
我得错了分店吗?因为我正在发布并使用核心2.0
我是新来的,如果我遗漏了一些明显的东西,我会道歉.我已经运行了dotnet ef命令,但是在我看的任何地方都看不到db - 比如在sql express或LocalDb中.我在端口5000上运行vs17的Identity Server项目
如果我运行MvcClient项目,我会看到带有安全链接的主页.如果我点击我指向IS4实例,但alice和bob登录将工作.(无效我们/ pw).我可以在日志中看到alice和bob用户没有在内存中创建
我正在开发 Asp.Net Core 应用程序
我想在运行应用程序后更改配置设置
我正在使用 IOptionsMonitor,但它没有检测到变化
在 Startup.cs -> Configuration() 方法中我有
services.Configure<Config>(Configuration.GetSection("someConfig"));
Run Code Online (Sandbox Code Playgroud)
在读取这些配置设置的另一个类中,我写了类似的东西
var someConfig= serviceProvider.GetRequiredService<IOptionsMonitor<Config>>();
Run Code Online (Sandbox Code Playgroud)
但是当我更改配置文件(Json File)时,没有检测到更改,并且someConfig没有更改。
配置 POCO 类:
public class Config
{
public string name {get; set;}
//More getters and setters
}
Run Code Online (Sandbox Code Playgroud)
编辑:
services.AddSingleton<ConfigHelpers>;
Run Code Online (Sandbox Code Playgroud)
我正在使用一个单例对象,我试图在其中读取配置。如果它不是 snigleton,它工作正常。即使在单例对象中,有没有办法更改配置?
在 ConfigHelpers.cs
var someConfig= serviceProvider.GetRequiredService<IOptionsMonitor<Config>();
Run Code Online (Sandbox Code Playgroud)
由于它在 Startup.cs 中定义为单例,因此不会反映对 Config 所做的更改。
我正在尝试将 reCaptcha v2 添加到我的 ASP.Net Core 网站。网站上大约有 30 多个页面,每个页面在内容的各个点都有一个“联系”表单部分。
我有本节的局部模型和视图模型,我将其包含在每个视图中:
部分调用:
@Html.Partial("_GetInTouchSection", GetInTouchViewModel)
Run Code Online (Sandbox Code Playgroud)
查看型号:
public class GetInTouchViewModel
{
[Required(ErrorMessage="Please enter your name")]
public string Name { get; set; }
[Required(ErrorMessage = "Please enter your company name")]
public string CompanyName { get; set; }
[Required(ErrorMessage = "Please enter your telephone number")]
public string TelephoneNumber { get; set; }
[Required(ErrorMessage = "Please enter your email address")]
public string EmailAddress { get; set; }
[Required(ErrorMessage = "Please enter your message")]
public string Message …Run Code Online (Sandbox Code Playgroud) c# ×8
asp.net-core ×4
.net-core ×2
azure ×2
.net ×1
certificate ×1
charts ×1
coreclr ×1
macos ×1
recaptcha ×1