Tag: asp.net core

ASP.NET Core中的服务器端图形

我最近将ASP.NET MVC应用程序从ASP.NET升级到ASP.NET Core。 在我的控制器操作中,我有一段依赖System.Drawing创建个人资料图片的代码 using (FileStream stream = new FileStream(HttpContext.Server.MapPath($”~/Content/UserFiles/{AuthenticatedUser.Id.ToString()}.jpg”), FileMode.OpenOrCreate)) { Image image = Image.FromStream(model.DisplayPicture.InputStream); image.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg); } 图像数据作为Base64编码图像发布到服务器 data:image/png;base64,…. 由于.NET Core中没有System.Drawing ,是否还有其他库可以实现这一目标?

DNX SDK版本’dnx-clr-win-x86.1.0.0-beta8-15530’无法安装

我克隆了一个基于ASP.NET 5 Mvc 6 Beta 8的存储库.Visual Studio无法安装最新的DNX SDK。 这是错误消息:“DNX SDK版本’dnx-clr-win-x86.1.0.0-beta8-15530’无法安装。解决方案将使用DNX SDK版本’dnx-clr-win-x86.1.0.0 -beta7’为本次会议。 我试图运行dnvm升级,但它说我已经有了最新版本。 这是存储库: https : //github.com/Kukkimonsuta/Odachi/tree/master/src/Odachi.Security.BasicAuthentication (这是实现基本身份validation的中间件的示例)。 此代码是否可能使用某些尚未用于dnvm的beta版本? 更新 C:\Windows\system32>dnvm upgrade -u Determining latest version Downloading dnx-clr-win-x86.1.0.0-rc1-15798 from https://www.myget.org/F/aspnetvnext/api/v2 Installing to C:\Users\mjost\.dnx\runtimes\dnx-clr-win-x86.1.0.0-rc1-15798 Adding C:\Users\mjost\.dnx\runtimes\dnx-clr-win-x86.1.0.0-rc1-15798\bin to process PATH Adding C:\Users\mjost\.dnx\runtimes\dnx-clr-win-x86.1.0.0-rc1-15798\bin to user PATH Updating alias ‘default’ to ‘dnx-clr-win-x86.1.0.0-rc1-15798’ 似乎没有做到预期。 在执行dnvm upgrade -u后打开解决方案时,我收到了相同的错误消息 它仍然无法编译。 如何安装所需的精确dnx? 更新我更新到稳定的测试版8但仍然有错误。 […]

dotnet core方法’ValidateOptions’…没有实现

我正在构建一个.NET Core解决方案,它正在构建得很好,但是当我尝试发布它时,会出现以下错误: Method ‘ValidateOptions’ in type ‘Microsoft.CodeAnalysis.CSharp.CSharpCompilationOptions’ from assembly ‘Microsoft.CodeAnalysis.CSharp, Version=2.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35’ does not have an implementation. at Microsoft.CodeAnalysis.CSharp.CSharpCompilation.Create at Microsoft.CodeAnalysis.Razor.CompilationTagHelperFeature.GetDescriptors() at Microsoft.AspNetCore.Razor.Language.DefaultRazorTagHelperBinderPhase.ExecuteCore(RazorCodeDocument codeDocument) at Microsoft.AspNetCore.Razor.Language.DefaultRazorEngine.Process(RazorCodeDocument document) at Microsoft.AspNetCore.Razor.Language.RazorTemplateEngine.GenerateCode(RazorCodeDocument codeDocument) at Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.Internal.PrecompileRunCommand.c__DisplayClass23_0.b__0(Int32 i) at System.Threading.Tasks.Parallel.c__DisplayClass19_0`1.b__1(RangeWorker& currentWorker, Int32 timeout, Boolean& replicationDelegateYieldedBeforeCompletion) — End of stack trace from previous location where exception was thrown — at […]

引用ASP.NET Core中的现有.NET Framework项目

我有一个.NET Framework 4的现有项目,它是一个业务逻辑层 我创建了带有核心框架的.NET核心应用程序,并尝试添加存在的业务层作为参考,我尝试使用此示例: 如何在.NET Core项目中引用.NET Framework项目? 我还使用.net框架创建了核心应用程序并尝试添加引用它也无法正常工作 请检查下面的图像,并给我帮助:) ——— .net framework —— core project

通过.NET Core上的MEF将参数传递给插件构造函数?

我花了几个小时试图弄清楚如何通过MEF(System.Composition)将参数传递给插件构造函数,但都无济于事。 毋庸置疑,相关文档很少,通过源代码看看也无济于事。 这曾经很容易使用CompositionHost.ComposeExportedValue方法,但在.NET Core版本中我似乎无法找到任何有用的东西。 我在下面附上了我的不完整代码,然后是抛出的exception。 在这方面的任何帮助将不胜感激。 谢谢…. using System; using System.Composition; using System.Composition.Hosting; using System.Reflection; namespace MefMe { public interface IPlugin { void Alert(); } [Export(typeof(IPlugin))] public class Plugin : IPlugin { private string code; [ImportingConstructor] public Plugin(string code) { this.code = code; } public void Alert() => Console.WriteLine(code); } class Program { static void […]

如何使用Entity Framework 7在代码中首先处理这两个模型?

问题 我正在编写将模拟库的概念ASP.NET 5 MVC6的certificate。 我正在使用CTP6和beta3。 如何使用代码优先方法在Entity Framework 7中定义它们的关系? 货架和书籍需要连接表。 在我看来,这个应用程序将一次考虑一个架子和自己的书籍。 换句话说,一个书架与书籍有一对多的关系。 楷模 货架型号: public class Shelf { public int ShelfId { get; set; } public string ShelfName { get; set; } public ShelfType MyProperty { get; set; } public virtual List Books { get; set; } public DateTime Created { get; set; } public string […]

如何在找不到DLL时调试dotnet.exe?

我有一个ASP.NET MVC Core 2.0应用程序,当我构建它时,输出DLL文件在bin\Debug\netcoreapp2.0中创建。 当我使用默认值发布它时,发布的输出在bin\Debug\netcoreapp2.0\Publish文件夹中创建。 现在,当我使用dotnet从Publish文件夹启动我的应用程序时,一切正常。 dotnet D:\Project\bin\Debug\netcoreapp2.0\Publish\Project.dll 但是,当我使用dotnet从netcoreapp2.0启动我的应用程序时,它抱怨它无法找到所需的DLL文件。 dotnet D:\Project\bin\Debug\netcoreapp2.0\Project.dll // this breaks Project.dll依赖于另一个库,该库存在于netcoreapp2.0和Publish文件夹中。 为什么dotnet可以从一个文件夹加载它,并且无法从另一个文件夹加载它? 我该如何调试?

在OpenIddict中处理请求时发生未处理的exception

所以,我正在尝试使用.net核心1.1实现OpenIddict版本1.0.0-beta2-0580,我收到以下错误: 处理请求时发生未处理的exception 这是基于此: https : //github.com/openiddict/openiddict-core/tree/dev/samples db正确注册数据库,加载设置,一切都在这里工作。 数据库中的表格: __efmigrationshistory , aspnetroleclaims , aspnetroles , aspnetuserclaims , aspnetuserlogins , aspnetuserroles , aspnetusers , aspnetusertokens , basetransaction , openiddictapplications , openiddictauthorizations , openiddictscopes , openiddicttokens 然后我有 堆栈跟踪: InvalidOperationException: The authentication ticket was rejected because the mandatory subject claim was missing. AspNet.Security.OpenIdConnect.Server.OpenIdConnectServerHandler+d__5.MoveNext() System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) Microsoft.AspNetCore.Authentication.AuthenticationHandler+d__66.MoveNext() System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task […]

ASP.NET 5中System.Web.Mvc.Html.InputExtensions的等价物是什么?

ASP.NET 4中使用的ASP.NET 5等效的System.Web.Mvc.Html.InputExtensions是什么? 见下面的例子: public static class CustomHelpers { // Submit Button Helper public static MvcHtmlString SubmitButton(this HtmlHelper helper, string buttonText) { string str = “”; return new MvcHtmlString(str); } // Readonly Strongly-Typed TextBox Helper public static MvcHtmlString TextBoxFor(this HtmlHelper htmlHelper, Expression<Func> expression, bool isReadonly) { MvcHtmlString html = default(MvcHtmlString); if (isReadonly) { html = […]

ASP.NET 5 Identity 3用户在应用程序重新启动后退出

我们正在使用ASP.NET Identity 3。 我们的用户会随机自动退出。 为了重现这个问题,我尝试重启应用程序,所有用户都退出了,即使是那些已经检查过的人也Remember me 。 它只发生在Production中,在开发环境中工作正常。 更新: 我们只有一台服务器在生产中。