asp.net-mvc-5

Automapper map child list with from same type

谁都会走 提交于 2019-12-11 04:58:30
问题 I have entities that may have children and their children may have children and so on... When I get database models all entities are OK with correct children and parent. But the problem comes when I want to map to view model: Is there any possible way to map models from database like this? // database model code first public class Tomato { public int Id { get; set; } public string Name { get; set; } public int? ParentId { get; set; } public virtual Tomato Parent { get; set; } public

How to override global ModelBinder for specific post action mvc5

你离开我真会死。 提交于 2019-12-11 04:42:23
问题 I have applied a global ModelBinder for int arrays as below: public class IntArrayModelBinder : DefaultModelBinder { public override object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) { var value = bindingContext.ValueProvider.GetValue(bindingContext.ModelName); if (string.IsNullOrEmpty(value?.AttemptedValue)) { return null; } try { return value .AttemptedValue .Split(',') .Select(int.Parse) .ToArray(); } catch (Exception e) { Console.WriteLine(e);

Accessing CDN bundles on different ASP.Net MVC site

筅森魡賤 提交于 2019-12-11 04:26:48
问题 This is a follow-up question to this: ASP.Net MVC 5 - Deploy separate CDN site with bundled JavaScipt and CSS I want to serve up my JavaScript and CSS bundles from a second ASP.Net website, so I have done the following. Main website (ASP.Net MVC website that has not JS or CSS resources) CDN website (ASP.Net MVC website that has all JS and CSS resources but not much else) CDN Website Web.config extract <system.webServer> <httpProtocol> <customHeaders> <add name="Access-Control-Allow-Origin"

Parallel file upload XMLHttpRequest requests and why they won't work

匆匆过客 提交于 2019-12-11 04:24:52
问题 I am trying to upload many (3 for now) files in parallel using XMLHttpRequest. If have some code that pulls them from a list of many dropped files and makes sure that at each moment I am sending 3 files (if available). Here is my code, which is standard as far as I know: var xhr = item._xhr = new XMLHttpRequest(); var form = new FormData(); var that = this; angular.forEach(item.formData, function(obj) { angular.forEach(obj, function(value, key) { form.append(key, value); }); }); form.append

Sitecore glass editable cannot convert lambda expression

为君一笑 提交于 2019-12-11 04:08:42
问题 I'm using Sitecore 7.5, MVC 5.2 and Glass Mapper 3.2. When using Editable() in the renderings, the error below is shown in visual studio even though it renders properly when using the site and/or the page editor. Am I missing a reference or something? Error: "Cannot convert lambda expression to type 'System.Linq.Expressions.Expression>' because it is not a delegate type" View @using Sitecore.Mvc @using Sitecore.Mvc.Presentation @inherits Glass.Mapper.Sc.Web.Mvc.GlassView<Air.SitecoreModels

ASP.NET MVC 5 Ninject: Ninject.MVC3/5

早过忘川 提交于 2019-12-11 04:06:53
问题 I want to add Ninject to an ASP.NET MVC 5 Project. NinjectWebCommon.cs is not in the App_Start folder. In a tutorial I read that Ninject.MVC3 should be added via Nuget. If I go into 'Manag NuGet Packages' and search for 'Ninject' I get the following: There I find 'Ninject.MVC5'. A symbol indicates that this package is installed. But when I go to 'Installed packages' I see the following: Here I cannot find this package. Why is the package not listed here? Should I install 'Ninject.MVC3'

ASP.NET MVC path with file extension

白昼怎懂夜的黑 提交于 2019-12-11 03:57:54
问题 In ASP.NET MVC5 using attribute-based routing, I want to handle URLs with file extensions, eg ~/javascript/security.js Here's an example controller action method: [Route("javascript/security.js")] public ActionResult AngularSecurityModule(string clientId) { return View(new { ClientId = clientId }); } However, this gives me an HTTP 404 - Not Found. I'd prefer to not use runAllManagedModulesForAllRequests (eg <system.webServer> <modules runAllManagedModulesForAllRequests="true" /> </system

Uploaded file not saving to file system

怎甘沉沦 提交于 2019-12-11 03:57:51
问题 Context I am creating a media library for a CMS that I am building. The basic function includes uploading a file and storing it in a file system. However, it creates an id for the saved file Currently I am testing through what I have built via localhost . db.Files.Add(mediafile); adds the name of the file, however, it does not add an image to the directory. Question How do I save posted files to a directory? (The Commented Section) Source Code /Areas/Media/Controllers/FilesController.cs

Cors with MVC5, Webapi and Angular Js

南笙酒味 提交于 2019-12-11 03:52:40
问题 I'm testing a simple Visual studio solution with two project: project A: web project where there same angular code, i.e login/function to autenticate user (post to account api to project B). Account Api give me token based on user/name. project B: web api where I can get same simple data (http GET), and where there are same account api (i.e. integrated api/token that give me auth token based on credential). Either project are hosted on the same server but with different name and port: http:/

What is the hash logic in MVC 5 Identity

那年仲夏 提交于 2019-12-11 03:52:35
问题 I am new to MVC 5 Identity. I am trying to find what is the hash logic for password in mvc 5 identity. I am trying to validate user outside .net project but using its table AspNetUsers. If I am correct in mvc 4 it was SHA1?? But I am not sure whats the same in MVC 5. Also can we validate user in table AspNetUsers within the sql server using sql script itself? Regards & Thanks. 回答1: From https://github.com/aspnet/Identity/blob/dev/src/Microsoft.AspNetCore.Identity/PasswordHasher.cs Version 2: