问题标签 [asp.net-core-2.0]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
asp.net - ASP.Net / ASP.NET Core Web API unauthorized requests returns 302 redirect response instead of 401
In ASP.Net / ASP.Net Core WebAPI,
When the client/browser tries to access a WebAPI endpoint which is decorated with [Authorized]
attribute. It gets a 302-Found
status code with a redirect response to the Login page, instead of 401-Unauthorized
for an unauthorized request.
Note: I have noticed that Fail(AuthorizationContext context)
method in AuthorizeAttribute filter sets the response code as 401-Unauthorized
, but eventually browser gets a 302-Found
response.
How can I send the 401 response instead of 302 ?
UPDATE: Update the question with ASP.NET Core
asp.net - ASP.NET Core 1.0 ConfigurationBuilder().AddJsonFile("appsettings.json"); 找不到文件
所以我终于开始关注Core,我在第一关就掉了下来。我正在学习 Pluralsight ASP.NET Core Fundamentals 课程,并且在尝试将 appsettings.json 文件添加到配置生成器时遇到异常。
我得到的错误是找不到配置文件'appsettings.json'并且不是可选的。但是我直接在我的解决方案下创建了,就像在课程视频中一样。
.net - cs项目文件和nuspec文件的未来
我们已将我们的应用程序(由 20+- 项目和 5 个可执行文件组成)移至 asp net core (1.1) 和 project.json (.xproj)。
我们让它全部运行,但现在我们正在将某些项目作为包移动到我们的内部 nuget 提要。我们可以使用 project.json 来创建 nuget 包,但我们仍然可以使用 nuspec 文件来创建包(尽管这些占位符不再自动填充)。
自从微软宣布他们将放弃 project.json 并回到他们旧的 xml 项目结构,我想知道 nuspec 支持会发生什么?
我一直在研究这个,但找不到任何关于这个的信息。
有谁知道这个项目文件的未来将如何包含 nuspec 支持,或者仍然需要 nuspec 文件?
找到相关资源:
- 项目 json 文档:https ://docs.microsoft.com/nl-nl/dotnet/articles/core/tools/project-json 说他们搬到 msbuild
- 解释原因:https ://blogs.msdn.microsoft.com/dotnet/2016/05/23/changes-to-project-json/
macos - Visual Studio Mac 与 dotnet core 2 不兼容
我使用 Visual Studio Mac 已经有一段时间了,刚刚将其更新到发布版本。我还下载并安装了 .NET Core 2.0 Preview 1。在 shell 提示符下,我可以生成一个新的 Web API 项目:
我可以从 shell 构建和运行该项目。但是当我在 Visual Studio for Mac 中打开它时,IDE 会尝试恢复但无法恢复:
asp.net-core - 如何在 AspNet Core Mvc 中使用 Crystal 报表
我已将现有的 Erp 应用程序从Ap.net MVC转换为AspNetCore.Mvc。我想将水晶报表集成到新应用程序中。我已经添加了参考
- CrystalDecisions.CrystalReports.Engine.dll
- CrystalDecisions.ReportSource.dll
- CrystalDecisions.Web.dll
但是当我尝试使用CrystalDecisions.CrystalReports.Engine ReportDocument 的Load、SetDataSource函数时,它显示编译错误为:
类型“IDataReader”是在未引用的程序集中定义的。您必须添加对程序集“System.Data,Version=2.0.0.0,Culture=neutral,PublicKeyToken=b77a5c561934e089”的引用。
这是我加载水晶报表的代码
在 AspNetCore.Mvc 中使用水晶报告有更好的选择吗?
感谢和问候 Sunij K
c# - .NET Core 中 HttpListener 的模拟是什么
我正在将应用程序从 .NET 4 移植到 .NET Core,但找不到 HttpListener 类的模拟
更新1
c# - .NET Core 中是否有 HtmlTableRow 的模拟
我正在将应用程序从 .NET 移植到 .NET Core,但找不到 HtmlTableRow 类的模拟
mysql - 将 Pomelo MySQL EF 提供程序与 ASP.NET Core 2.0 预览版一起使用时出错
我在 ASP.NET Core 2.0 预览版上使用 Pomelo 1.1.2 以及 EF 2.0 预览版。使用他们的演示代码,每次调用“UseMySql”时都会出现以下异常:
想知道这是否仅仅是因为 2.0 预览库?有任何想法吗?我试图在 Git 上查看他们的源代码,看看我是否可以立即发现任何错误,但不能。
asp.net-core - 从 ApplicationDbContext 到 IdentityServiceDbContext
在 ASP.NET Core 1.1 中,我使用 ApplicationDbContext 作为用户身份上下文和我的模型数据,遵循this。
并在启动-> 配置中:
现在我正在尝试asp.net core 2 preview。
但是现在我们有了 IdentityServiceDbContext:
问题是:我可以为我的数据使用 IdentityServiceDbContext 还是应该创建单独的 dbcontext?
看起来他们将 IdentityServiceDbContext 移至身份服务。