asp.net-core-mvc

MVC 6 WebFarm: The antiforgery token could not be decrypted

妖精的绣舞 提交于 2019-12-12 08:04:27
问题 I'm running MVC 6 (vNext) in a webfarm scenario (ARR front-end with multiple AppServers). Server affinity is off. When I bounce between app servers from one request to another I get the error CryptographicException: The key {3275ccad-973d-43ca-930f-fbac4d276640} was not found in the key ring. InvalidOperationException: The antiforgery token could not be decrypted. Previously, I believe this was handled by setting a static MachineKey in the web.config. As I understand it, we've now moved to a

Require SSL Client Certificate only for specific routes or controllers

北城以北 提交于 2019-12-12 07:47:59
问题 I have an ASP.NET MVC Core project using Kestrel as the server. It is both serving up user content (asp.net mvc) and hosts web API controllers that agents (software) communicate with. I have enabled HTTPS and client certificate support. The issue is that I want to require client certificates for agents (software) that call Web APIs but I do not want to require/prompt for client certificates for regular browser based users. I have enabled HTTPS/client certificate support the following way: var

How to access current absolute Uri from any ASP .Net Core class?

*爱你&永不变心* 提交于 2019-12-12 07:46:00
问题 I am trying to figure out how to access the current absolute Uri -- i.e. the absolute url of the view that is currently being rendered -- from a user class in .Net Core 1.1 I found this link but it seems to be outdated and throws error after error: Getting absolute URLs using ASP.NET Core MVC 6 In my Startup.cs I have under ConfigureServices : services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>(); In my Startup.cs I have under Configure: IHttpContextAccessor httpContextAccessor =

ASP.NET 5 MVC 6 Generic Repository Pattern

无人久伴 提交于 2019-12-12 07:38:24
问题 Been looking every where for a tutorial or something. I've been trying to implement my old generic repository pattern for MVC5 into a new MVC6 project. I set up 3 class library's .Core , .Data and .Service , However there's an issue with IDBset , seems my intellisense doesn't like it, I tried to add System.Data and Entity framework 6 but without any luck (cant find it...confusing). After roaming google I decided to ask here, is there a tutorial with the correct way or can someone throw up a

How to access HttpContext inside a unit test in ASP.NET 5 / MVC 6

£可爱£侵袭症+ 提交于 2019-12-12 07:09:42
问题 Lets say I am setting a value on the http context in my middleware. For example HttpContext.User. How can test the http context in my unit test. Here is an example of what I am trying to do Middleware public class MyAuthMiddleware { private readonly RequestDelegate _next; public MyAuthMiddleware(RequestDelegate next) { _next = next; } public async Task Invoke(HttpContext context) { context.User = SetUser(); await next(context); } } Test [Fact] public async Task UserShouldBeAuthenticated() {

Customize Login Page design for Authentication type : Individual User account ASP.NET core 2.1, MVC, c#

Deadly 提交于 2019-12-12 07:06:58
问题 I'm trying to implement OAuth2.0 for my web application. I have done that following this link. I have registered with 2 external providers Microsoft and google. I have added Authentication in startup.cs file as well. So when I run the application, click on Login button on top right corner, a Login page is displayed.The URL it is showing is https://localhost:44325/Identity/Account/Login . But I'm unable to find this page anywhere in my solution. I want to modify this page's design and want to

Communication in ASP.NET Core

守給你的承諾、 提交于 2019-12-12 06:39:45
问题 Situation: I need to create some kind of controlling part of the communication over Modbus TCP/IP in my ASP.NET Core project. Communication is working correctly with Modbus, but I need to read some Modbus addresses pernamently and I need to set them interval. I have such structure for this in db. I have now singleton called CommunicationRepository, which is such controller for this protocol and have methods to read from the module, write to module, have structure for data from modules, etc.

Custom Tag helper debugging

这一生的挚爱 提交于 2019-12-12 06:25:27
问题 I'm trying to test a new tag helper that I'm trying to create. I've stumbled into a shortcoming of the new .net core validation and cannot change the class post validation. So if I wanted to give my errors a red background, the span is always there and won't change. So, I've decided to make my own tag helper. the problem is I can't seem to get it to work or trigger. I can't even get it to hit a break point. Here is what I have for a tag helper so far. namespace MusicianProject.TagHelpers { //

Load data for jqgrid using json doesn't work

耗尽温柔 提交于 2019-12-12 06:19:01
问题 I'm getting crazy, could you help me please, the grid rows doesn't appear and i don't know why it is really disturbing i spent more than 3 days trying, i realllly need help here!!!! My Action Method: [HttpGet] [Produces("application/json")] public JsonResult GetSearches(string sidx, string sord, int page, int rows,string name) { var ls = db.Candidates.Select( z => new { z.ID, z.Name, z.Email } ); int pageIndex = Convert.ToInt32(page) - 1; int pageSize = rows; int totalRecords = ls.Count();

Localization Files in Asp.Net Core

雨燕双飞 提交于 2019-12-12 05:00:12
问题 I don't have much experience working with resource files, but the little that I have is from Web Forms. There from what I can tell is you create a resource file called let's say InternalMessages.resx and then you create a Spanish version Errors.es.resx. Now if I have set up my code correctly for choosing language, all I have to do it call InternalMessages.MyMessage and it will choose the right language, regardless of what page you are on. In core, this concept doesn't seem to work. no matter