asp.net-mvc-5

How can I get Glimpse to work with EF6?

不想你离开。 提交于 2019-12-22 04:16:06
问题 EDIT : stack trace added at bottom. I have an ASP.NET MVC 5 project that uses a SQL Server database via Entity Framework 6. I added Glimpse (and Glimpse.MVC5) to the project, and that works fine. However, when I add Glimpse.EF6, my application throws an exception as soon as it attempts to access the database. The exception is: System.NotSupportedException Unable to determine the provider name for provider factory of type 'System.Data.SqlClient.SqlClientFactory'. Make sure that the ADO.NET

How to store session data in .NET MVC 5

混江龙づ霸主 提交于 2019-12-22 01:32:37
问题 Can I use the HttpContext.ApplicationInstance.Context class to store session data using the Session function? Or there is a better way to do this? 回答1: Normally the session is available as a property in your controller actions: public ActionResult Index() { this.Session["foo"] = "bar"; return View(); } Since the Session property is of type HttpSessionStateBase it can be more easily mocked in a unit test. Please never use the static HttpContext.Current.Session as you might see suggested

ASP.Net Identity customizing UserProfile

别等时光非礼了梦想. 提交于 2019-12-22 01:15:48
问题 I'm writing an MVC5 app with EF. I added ASP.NET Identity to the project which created ASPNETUser Tables in my DB the first time I registered a user. However now, when I try to customize UserProfile (as listed in this post: http://www.asp.net/mvc/tutorials/mvc-5/create-an-aspnet-mvc-5-app-with-facebook-and-google-oauth2-and-openid-sign-on) I get the following: The model backing the 'ApplicationDbContext' context has changed since the database was created. Consider using Code First Migrations

Extending asp.net identity in asp.net mvc 5 application

烂漫一生 提交于 2019-12-22 00:18:21
问题 I am working on asp.net MVC 5 application. I am using Identity for creating users. I am using it first time and creating first mvc 5 application. I have two types of users. I want two tables for both types of users. So first record should be inserted in aspnetuser table and then in related tables and aspnetuser table should be linked with both tables so that i can access them. I have created models for both types of users. How can i link them with identity in model ? Please suggest 回答1: Well,

Visual Studio 2015. Failed to register URL for site access is denied IIS Express. Access denied 0x80070005

痴心易碎 提交于 2019-12-21 22:59:54
问题 I enabled SSL in Visual Studio 2015 in order to implement Facebook and Google login locally. I changed the project URL in the Web tab of the project's properties to https://localhost:44300/ and decorated the controller with the RequireHttps attribute - ref @msdn. Everything worked fine locally. I reverted settings to HTTP to test something else and that caused me a problem when I tried to get back to HTTPS. I found this SO question and tried almost every suggested solution. Error detail:

How update/edit uploaded files in asp.net mvc 5 without redundancy?

别等时光非礼了梦想. 提交于 2019-12-21 21:56:39
问题 I have a problem with update data in Asp.net MVC 5 with Razor Engine . my Update code works fine but I have some problems with it . When I update Image , old image stays in Images folder . I want to delete old image if it changed . and I want to stay old image if it didn't change . How can I do it ? Thanks a lot for any help I don't know how write if statement for this :/ CarouselRepositories.cs public bool Update(NP1.Models.Carousel entity, bool autoSave = true) { try { db.Carousels.Attach

How to access HTTP StatusDescription in custom error page

岁酱吖の 提交于 2019-12-21 21:29:30
问题 When an action (asp.net mvc 5) cannot find something in the database, the user must see a page with a short custom error message e.g. "Invoice 5 does not exist" . Also, the response must have a 404 HTTP code. Another example: when the action is improperly called, the user must see e.g. "Parameter 'invoiceId' is required" . Also, the response must have a 400 HTTP code. I tried to store the custom messages in the HTTP status description and to display them in custom error pages. There are two

bootstrap modal for delete confirmation mvc

南楼画角 提交于 2019-12-21 20:38:03
问题 I'm developing an MVC 5 web application. Within one of my Razor Views I have a table which spits outs several rows of data.Beside each row of data is a Delete button. When the user clicks the delete button I want to have the Bootstrap Modal popup and ask the user to confirm their deletion. add line before foreach loop @Html.Hidden("item-to-delete", "", new {@id = "item-to-delete"}) @foreach (var item in Model) { <td> <button type="" class="btn btn-sm blue deleteLead" data-target="#basic" data

date format dd/MM/yyyy not working in asp.net mvc 5

混江龙づ霸主 提交于 2019-12-21 20:14:38
问题 I'm developing an asp.net mvc 5 application, in which I'm trying to set a validation for dd/MM/yyyy format, I've been struggling a lot to find an appropriate solution but no success, what I want it to accept: 24/01/2016 but it displays validation message as : The field JoiningDate must be a date. Here is what I've tried : [DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}", ApplyFormatInEditMode = true)] public DateTime JoiningDate { get; set; } Also, I want it to display the date in dd/MM

Unity 3 Configuration By Convention not finding Types in Web Project

人走茶凉 提交于 2019-12-21 18:06:22
问题 I am trying to get this convention configuration working but I am having a problem in my ASP.NET MVC5 Project.. I have added the following in my Application_Start method and hooked it up to DependencyResolver public static IUnityContainer CreateContainer() { IUnityContainer container = new UnityContainer(); container.RegisterTypes( AllClasses.FromAssembliesInBasePath(), WithMappings.FromAllInterfaces, WithName.Default, WithLifetime.ContainerControlled); return container; } But it fails to