asp.net-core-mvc

Why “Method not found: 'Void System.Web.Http.HttpResponseException..ctor” after package update?

橙三吉。 提交于 2019-12-21 05:36:07
问题 I have an ASP.NET MVC application which started to misbehave after the last NuGet package updates. The web app uses .NET Framework 4.6.1, and the developer machine is a Windows Server 2012 R2 Essentials. One package I use is Stripe.NET for payment processing. Its earlier versions required only <package id="System.Net.Http" version="4.0.0" targetFramework="net461" /> . Visual Studio marked that there's a newer version of that (at that time it was 4.3.0 ), but when I updated that it pulled in a

Posting multiple forms on MVC Razor View with a Single View Model

只愿长相守 提交于 2019-12-21 04:55:07
问题 I have a razor view that will contain 5 forms. (A, B, C, D, E). Each of these forms has their own ViewModel (AViewModel, BViewModel, CViewModel, DViewModel, EViewModel). I created a parent ProductViewModel that the page will use as its only ViewModel. Within this ViewModel will be all of the other ViewModels for each form on the page (listed above). Here is what the ProductViewModel's properties look like: public AViewModel { get; set; } public BViewModel { get; set; } public CViewModel { get

Windows Authentication support in ASP.NET 5 beta 8

别说谁变了你拦得住时间么 提交于 2019-12-21 04:39:40
问题 I have an ASP.NET 5 MVC 6 Web API project. Most of the API endpoints have the [Authorize] attribute, and Windows Authentication is enabled in both IIS and on the properties of the project in Visual Studio. This all works fine in beta 7. In beta 8, however, this does not work. It's easy to reproduce this with a completely clean project: Create a new project using the ASP.NET 5 Web API template. Get properties on the project (not the solution), go to the Debug tab, enable Windows authentication

How to cache css,js or images files to asp.net core

强颜欢笑 提交于 2019-12-21 04:28:25
问题 An intermittent proxy was causing my pages to get cached with an asp.net core site I deployed. The web server was not caching pages. I added request and response caching to prevent any caching this proxy was causing In my Startup.cs app.UseStaticFiles(); app.UseIdentity(); app.Use(async (context, next) => { context.Response.Headers.Append("Cache-Control", "no-cache"); context.Response.Headers.Append("Cache-Control", "private, no-store"); context.Request.Headers.Append("Cache-Control", "no

Get AuthenticationProperties in ASP.NET 5

吃可爱长大的小学妹 提交于 2019-12-21 04:08:23
问题 In ASP.NET 5 MVC 6 RC1 how do I retrieve AuthenticationProperties from within a controller or from a filter? HttpContext.Authentication does't seem to have this functionality. I thought about registering an CookieAuthenticationEvents.OnValidatePrincipal handler and then using the Properties property on the CookieValidatePrincipalContext argument. Then I could store those AuthenticationProperties in the request cache so that later I'm able to get things like IssuedUtc . Is there a better

How to disable precompiled views in net core 2.1 for debugging?

旧城冷巷雨未停 提交于 2019-12-21 03:34:10
问题 Yesterday I updated to net core 2.1. Now if I am debugging, the views getting precompiled, which ofcourse takes a long time during startup... Is it possible to fall back to the previous behavior, where the Views are compiled just in time, if it is needed? I have no reference related to precompilation in my csproj. Is it something that comes from the meta package? <ItemGroup> <PackageReference Include="JetBrains.Annotations" Version="11.1.0" /> <PackageReference Include="Microsoft.AspNetCore

Create list of entities in asp.net core mvc

只愿长相守 提交于 2019-12-21 02:58:13
问题 I want to create an entity in asp.net core mvc. The entity represents an exercise workout, and it has a child collection of exercise sets: public class Workout { public DateTime Date { get; set; } public string Name { get; set; } public string Description { get; set; } public virtual ICollection<Set> Sets { get; set; } } public class Set { public int Id { get; set; } public int ExerciseId { get; set; } public int WorkoutId { get; set; } public decimal Weight { get; set; } public int Reps {

Force locale with Asp.Net Core

偶尔善良 提交于 2019-12-21 02:57:15
问题 I'm having some odd issues with a web application written using Asp.Net Core 1.1, using the full .Net Framework v4.6.2. I want to force the application to use a swedish locale (sv-SE). This is working just fine on the development machine (of course...) but not on the server where it's supposed to run (running Windows Server 2012r2). I've tried the following: 1) Putting "SiteLocale": "sv-SE" in the appsettings.json file. 2) Putting the following in the web.config <configuration> <system.web>

BrowserLink does not work for ASP.NET Core on Visual Studio 2017 RTM

随声附和 提交于 2019-12-21 01:59:33
问题 I get the following error in the browser when I enable BrowserLink for my ASP.Net Core 1.1 application and I think because of that the BrowserLink does not work. Browser Link: Exception thrown when trying to invoke Browser Link extension callback "microsoft.visualstudio.web.browserlink.sourcemappingextensionfactory.getCssMappingData": System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not

How to implement global.asax events by OWIN

久未见 提交于 2019-12-21 01:59:33
问题 from asp.net 6 there would be no file called global.asax but global.asax has many events like · Application_Init · Application_Start · Session_Start · Application_BeginRequest · Application_EndRequest · Application_AuthenticateRequest · Application_Error · Session_End · Application_End say for example i often work with Application_BeginRequest event to redirect user. here is a sample code protected void Application_BeginRequest(Object sender, EventArgs e) { if (HttpContext.Current.Request.Url