asp.net-mvc-5

Using NHibernate interceptor together with Ninject to retrieve the logged in user

谁说我不能喝 提交于 2019-12-24 13:33:40
问题 I was reading this article and found it quite interesting (thanks @Aaronaught). Was what came closest to solve my problem. The only detail is that in my case I would use the NHibernate interceptor, but an exception is thrown An unhandled exception of type 'System.StackOverflowException' occurred in System.Core.dll Code Session factory: public class SessionFactoryBuilder : IProvider { private ISessionFactory _sessionFactory; private readonly Configuration _configuration; public

Is PUT broken by default in ASP.NET MVC?

丶灬走出姿态 提交于 2019-12-24 12:35:07
问题 I created a new ASP.NET MVC project, updated NuGet packages (to <package id="Microsoft.AspNet.Mvc" version="5.2.3" targetFramework="net451" /> ) and added a controller: public class HomeController : Controller { [AcceptVerbs(HttpVerbs.Get | HttpVerbs.Put | HttpVerbs.Post)] public string Index() { return "bombaclat"; } } I ran it on IIS Express and found out that PUT returns 404 from IIS StaticFile handler (both GET and POST works just fine). I can fix it either by allowing all verbs for

Transient System.Security.Cryptography.CryptographicException in TwilioRequestValidator

ε祈祈猫儿з 提交于 2019-12-24 12:17:39
问题 So we have our Twilio callbacks setup to validate incoming requests, via the TwilioRequestValidator documented here. However, something we're seeing, is that the production server will run for weeks with no problems, and then suddenly start failing with a CryptographicException. This causes all incoming Twilio requests to fail. We have a call-stack (thanks to Azure Application Insights): System.Security.Cryptography.CryptographicException: at System.Security.Cryptography

Entity framework - NotSupportedException in lambda expression

六眼飞鱼酱① 提交于 2019-12-24 10:49:21
问题 In my MVC application ApplicationUser and Employee classes have 1-1 relationship: public class ApplicationUser : IdentityUser { public Employee Employee { get; set; } } public class Employee { [Key] public virtual ApplicationUser ApplicationUser { get; set; } public virtual string Name { get; set; } } In a public static class I have following methods: public static ApplicationUser GetCurrentApplicationUser(string userName) { using (DbContext db = new DbContext()) { return db.Users

Submitting a model to action that is different from view model's type

我只是一个虾纸丫 提交于 2019-12-24 10:39:27
问题 I have two models: public class PersonViewModel { public int Id { get; set; } public string Name { get; set; } public string Title { get; set; } } public class DetailViewModel { public IEnumerable<string> Titles { get; set; } public PersonViewModel Person { get; set; } } The form is presented with two fields, the first field being the Name , the second field being the a dropdown of Titles (Mr., Mrs. Miss., etc.) The view for this page is strongly typed to DetailViewModel , and the Save method

Dependency Injection fails with MVC5 and Ninject

时光毁灭记忆、已成空白 提交于 2019-12-24 09:52:44
问题 I'm trying to inject a couple of classes in a controller, but I'm failing. This is what I've done: Added Ninject.Web.WebApi.WebHost and WebActivatorEx NuGet packages Created the following class under App_Start : NinjectWebCommon.cs using Microsoft.Web.Infrastructure.DynamicModuleHelper; using Ninject; using Ninject.Web.Common; using Ninject.Web.Common.WebHost; using MyProject; using MyProject.Models; using MyProject.Classes; using System; using System.Web; [assembly: WebActivatorEx

Could not load file or assembly 'Microsoft.ReportViewer.ProcessingObjectModel, Version=10.0.0.0

北战南征 提交于 2019-12-24 09:30:24
问题 Using MVC5 with rdlc to generate pdf, it's working fine in localhost, but when i deply the application to server when i try to generate report it has error that some assebly are missing..... Server Error in '/webapp' Application. Could not load file or assembly 'Microsoft.ReportViewer.ProcessingObjectModel, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. so far install in webs server iis 2012 1-

Is it possible to save a role with enum parameter using Identity?

廉价感情. 提交于 2019-12-24 09:24:13
问题 I am experimenting with creating a authorization with identity. So far eveything is working with the guidlines I have found online. However I want to modify the saving of roles. I have created an enum and I save this enum to aspNetRoles table (code will follow below). The way a role is saved to a user is via the following: UserManager.AddToRole(user.Id, "Admin"); I am not a fan of sending in a string as a second paramater and wish to send an enum instead. Is this possible? My code so far:

Issue when using IAppBuilder.UseWebApi

最后都变了- 提交于 2019-12-24 08:32:51
问题 I am creating a SPA (Singe Page Application) using WebApis in ASP .NET MVC5. For WebAPis I am using attribute routing. For requests other than Web API, I have configured a Catch-All route that maps to Home controller and Index action Here is my code I have the following configuration code in my StartUp.cs file using System.Web.Routing; [assembly: OwinStartup(typeof(MyApp.Startup))] namespace MyApp { public class Startup { public void Configuration(IAppBuilder app) { GlobalConfiguration

Select All checkbox on EditorFor MVC C# View

瘦欲@ 提交于 2019-12-24 08:31:23
问题 My current view is displaying a list of Employees. All rows and columns displayed are model bound. See my view code below: @using System.Linq @using DN_.Extensions @model DN_.Models.NotificationsModel <script src="~/Scripts/jquery-3.3.1.min.js"></script> <script type="text/javascript" language="javascript"> $(function () { $("#checkAll").click(function () { $("input[id='cb_Notify']").prop("checked", this.checked).change(); var count = $("input[name='cb_Notify']:checked").length; }) $("input