asp.net-mvc-5.1

Cascading DropdownList with MVC5, Ajax, C# and MSSQL Server

我的未来我决定 提交于 2020-01-02 08:56:11
问题 I'm quite new to MVC coming from windows forms and 3 tier architecture. I'm trying to figure out using cascading dropdownlists (DDL) populated from database. Im using MS SQL Server 2012, VS 2013 Currently I'm work on user questionnaire which users can select from multiple answers from DDL. Depend on some selections I need to change answers (again DDL) on next question. Database: Table DDLStacks : StackId | StackName 1 | Berry 2 | BerryColor 3 .... Table DDLStackContents (SCId Stack content id

MVC 5 -> MVC 5.1 Migration. Intellisense issues

做~自己de王妃 提交于 2019-12-30 06:54:34
问题 I just updated my project to MVC 5.1 from MVC 5. The main web.config file got updated automatically, but web.config s under main View and Areas folders weren't changed. I suspect that's why now I lost both intellisense and resharper support for my actions, controllers and areas. Does anyone know correct web.config content for MVC 5.1 Views? Just replacing 3.0.0.0 to 3.1.0.0 and 5.0.0.0 -> 5.1.0.0 did not solve the issue. It happens in both Visual Studio 2012 and 2013 Professional. 回答1: Found

ASP.NET MVC 5 error handling

巧了我就是萌 提交于 2019-12-27 17:29:30
问题 We want to handle 403 errors, 404 errors, all errors due to a MySpecialDomainException and provide a default error page for all other errors (including errors in the IIS configuration!). All errors should return proper Razor views, it would be very nice to have an ErrorController in front of the views. E.g. something like this: public class ErrorController : Controller { public ViewResult NotFound () { return View(); } public ViewResult Forbidden () { return View(); } public ViewResult

Why getting multiple instances of IMemoryCache in ASP.Net Core?

南楼画角 提交于 2019-12-21 09:19:15
问题 I have what I believe is a standard usage of IMemoryCache in my ASP.NET Core application. In startup.cs I have: services.AddMemoryCache(); In my controllers I have: private IMemoryCache memoryCache; public RoleService(IMemoryCache memoryCache) { this.memoryCache = memoryCache; } Yet when I go through debug, I end up with multiple memory caches with different items in each one. I thought memory cache would be a singleton? Updated with code sample: public List<FunctionRole> GetFunctionRoles() {

Change username in MVC 5

淺唱寂寞╮ 提交于 2019-12-20 20:41:58
问题 I am using ASP.NET MVC5 and Identity 2.0 (beta). It is possible for users to change the username? I am trying using UserManager.UpdateAsync method throws an exception. Regrads, Fran. 回答1: Yes it is possible using the UpdateAsync method but you need to ensure that you update both the email and username fields. var user = userManager.FindById(userId); user.Email = email; user.UserName = email; var updateResult = await userManager.UpdateAsync(user); This method works successfully for me 回答2:

migration synch developmental and production databases

只愿长相守 提交于 2019-12-17 21:23:49
问题 I am using MVC 5 with NET Framework 4.5.1. with Code-first. I am also using Migrations with the SQL 2012 server and (localdb)\v11.0. I am in the middle of developing a project using C# and MVC5. During development, I created a lot of new tables in my developmental computer and changed a the "Name" field which I believe the system makes an index for. I added it and deleted it several times. After that, I added a lot iof new unrelated tables, but for some reason, my migrations started giving me

Mvc 5.1 MissingMethodException System.Web.WebPages.TypeHelper.ObjectToDictionaryUncached

好久不见. 提交于 2019-12-17 19:47:05
问题 I'm update my MVC5 project to MVC5.1 and now have exception on route dictionary: routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); stack trace: {"Method not found: 'System.Web.Routing.RouteValueDictionary System.Web.WebPages.TypeHelper.ObjectToDictionaryUncached(System.Object)'."} at System.Web.Mvc.RouteCollectionExtensions.CreateRouteValueDictionaryUncached(Object values) at System.Web.Mvc.RouteCollectionExtensions.IgnoreRoute(RouteCollection routes, String url, Object constraints) at System

How to add role and Users in asp.net mvc 5?

对着背影说爱祢 提交于 2019-12-13 16:27:45
问题 I want to add User authorization and authentication in asp.net mvc project. I am Entity Framework Code First. Now I want to create some default user and default role for it. For this I want to create a Admin Role, but it is preventing me that User and Role Named admin and Admin Exists already. But when I see in my Database Table such as AspNetUSers , Role etc. there I did not find any named Admin. So how can I do this? If the admin role and users are built in, so where is the password. And

Populate a mvc5 list?

旧巷老猫 提交于 2019-12-13 06:33:59
问题 Right now I can create games under the Games/Create. And I can make a post under Post/Create. But my problem is that right now my public int GameId { get; set; } gets populated with the items that is in my Game table in my SQL database. Which is just fine that's how I like it. But I want public string Title { get; set; } to the populated the same way with the values that are in the Game database. public int GameId { get; set; } gets populated with a dropdownlist with the values that is in my

Why @Model haven't been passed to controller's action parameter by jquery script?

て烟熏妆下的殇ゞ 提交于 2019-12-13 05:26:55
问题 I wanted to pass Person object which is @Model in Details.cshtml (.../Person/Details/id) view to the Test action in PersonController which returns partial view Test.cshtml . The partial view is expandable/collapsable by the button so I use script. Everything works beside that @Model I try to pass to Test action is not passed-> it is null inside the Test action Why it(model) hasn't been passed and how pass it? Full code: Script: <script> function BtnOnclick() { $.ajax({ type: 'POST', url: '