asp.net-core-mvc

ValidateAntiForgeryToken in Ajax request with AspNet Core MVC

半世苍凉 提交于 2020-08-01 10:21:34
问题 I have been trying to recreate an Ajax version of the ValidateAntiForgeryToken - there are many blog posts on how to do this for previous versions of MVC, but with the latest MVC 6, none of the code is relevant. The core principle that I am going after, though, is to have the validation look at the Cookie and the Header for the __RequestVerificationToken , instead of comparing the Cookie to a form value. I am using MVC 6.0.0-rc1-final, dnx451 framework, and all of the Microsoft.Extensions

What is the markdown syntax for .NET Core templating

只谈情不闲聊 提交于 2020-07-21 07:31:48
问题 I have a .NET Core template and wondering how I can hide partial content from markdown file based on the flags set? As you may see below I tried what I do in CS project files but it didn't work. README.md # Steps - createSolutionFile.ps1 <!--#if (CacheSqlServer)--> - sql-cache.ps1 1. create database `DistributedCache` 2. create schema `cache` 3. run the script <!--#endif--> - user-secrets.ps1 <!--#if (EntityFramework)--> - scaffold.ps1 - migrate.ps1 <!--#endif--> - build.ps1 <!--#if

How to read data sent from web api using signalr in angular?

可紊 提交于 2020-07-21 06:14:27
问题 I want to read data sent from asp.net web api through signalr in angular client. For that, I created the Hub at my web api given below : //ProgressHub.cs public class ProgressHub : Hub { public Task Send(string data) { return Clients.All.SendAsync("Send", data); } public async Task<string> GetServerTime(IProgress<int> prog) { await Task.Run(() => { for (int i = 0; i < 10; i++) { prog.Report(i * 10); // Call to your client side method. Clients.Client(Context.ConnectionId).progress(i); System

Additionally password protect an ASP.NET Core MVC website hosted as Azure WebApp with existing authentication

空扰寡人 提交于 2020-07-21 03:08:08
问题 I have an existing ASP.NET Core MVC application with ASP.NET Core Identity where I use a combination of signInManager.PasswordSignInAsync and [Authorize] attributes to enforce that a user is logged in to website, has a certain role et cetera. This works fine locally and in an Azure WebApp. Now, I want to publish a preview version of my application to another Azure WebApp. This time, I want each visitor to enter another set of credentials before anything from the website is being shown. I

Additionally password protect an ASP.NET Core MVC website hosted as Azure WebApp with existing authentication

本小妞迷上赌 提交于 2020-07-21 03:08:06
问题 I have an existing ASP.NET Core MVC application with ASP.NET Core Identity where I use a combination of signInManager.PasswordSignInAsync and [Authorize] attributes to enforce that a user is logged in to website, has a certain role et cetera. This works fine locally and in an Azure WebApp. Now, I want to publish a preview version of my application to another Azure WebApp. This time, I want each visitor to enter another set of credentials before anything from the website is being shown. I

.net 5 is not available in Visual Studio 2019

牧云@^-^@ 提交于 2020-07-20 20:27:06
问题 I have downloaded and installed .NET Core 5.0 SDK (v5.0.100-preview.1) in my Visual Studio 2019. But it is not available in Target framework. Am I missing something? 回答1: You need to install the latest preview of Visual Studio 2019 16.6 , refer to https://devblogs.microsoft.com/aspnet/asp-net-core-updates-in-net-5-preview-1/ You also need to explicitly enable preview versions within Visual Studio itself: Then you should see it: 来源: https://stackoverflow.com/questions/60843091/net-5-is-not

.net core injecting and resolving services

落花浮王杯 提交于 2020-07-20 17:06:58
问题 I am trying my hand at .net core web api. I have created a static method for registering my controllers like this: public static class RegistrationExtensions { public static void RegisterApplicationServices(this IServiceCollection services, IServiceProvider serviceProvider) { services.RegisterSingletons(); services.RegisterRequests(); services.RegisterTransient(serviceProvider); } public static void RegisterSingletons(this IServiceCollection services) { services.AddSingleton<Configuration>();

.net core injecting and resolving services

China☆狼群 提交于 2020-07-20 17:06:08
问题 I am trying my hand at .net core web api. I have created a static method for registering my controllers like this: public static class RegistrationExtensions { public static void RegisterApplicationServices(this IServiceCollection services, IServiceProvider serviceProvider) { services.RegisterSingletons(); services.RegisterRequests(); services.RegisterTransient(serviceProvider); } public static void RegisterSingletons(this IServiceCollection services) { services.AddSingleton<Configuration>();

Asp.net core 2.0 Jwt doesn't ignore AllowAnonymous

故事扮演 提交于 2020-07-11 06:23:32
问题 I'm making a small new project using .net core 2.0 and jwt bearer authentication (https://github.com/aspnet/Security) Here is my Startup.cs /// <summary> /// This method gets called by the runtime. Use this method to add services to the container. /// </summary> /// <param name="services"></param> public void ConfigureServices(IServiceCollection services) { // Add entity framework to services collection. var sqlConnection = Configuration.GetConnectionString("SqlServerConnectionString");

Anchor tag helper withing area folder not generating route area name MVC Core 3.1

橙三吉。 提交于 2020-07-10 07:00:43
问题 I have Areas in application. One area name is Admin and it has SchoolController inside its controller folder and Views inside Views\School folder . When I use anchor tag inside Views\School\Index.html it is not working i.e not generating href attribute but if I place the same tag on layout or any other razor page which is not inside area, it is generating href tag. Anchor tag is - <a class="nav-link text-dark" asp-area="Admin" asp-controller="School" asp-action="Index">School</a> Routing