asp.net-mvc-5

Change OWIN Auth Middleware Per Request (Multi-tenant, oauth API keys per tenant)

限于喜欢 提交于 2019-12-18 11:13:11
问题 I have a multi-tenant application. Each tenant can authenticate its users using OAUTH-2 with Facebook, Twitter, Google, etc. Each tenant has its own API keys for the aforementioned services. The typical way to setup the OWIN pipeline is to "use" auth providers in Startup but this sets the API keys at app start. I need to be able to change which keys are used with each oauth API for each request. app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationType =

MVC5: UserManager.AddToRole(): “Error Adding User to Role: UserId not found”?

久未见 提交于 2019-12-18 11:04:45
问题 I have been experimenting with MVC5/EF6 and trying out the new Identity Authentication with Code-First Migrations. Everything in the solution is currently building and I can add a Migration , but when I perform an update-database through the package manager console in VS2013, my Configuration.cs file fails to fully process my test data into my Tables and outputs Error Adding User to Role: UserId not found . I have tried explicitly setting a User ID and leaving it to be generated by the

Integrate Angular 5 with ASP.NET MVC 5

我怕爱的太早我们不能终老 提交于 2019-12-18 10:56:30
问题 I am trying to integrate an Angular 5 app generated with CLI project into an existing ASP.NET MVC 5 application. I created the angular project with CLI inside the ASP.NET MVC project, and I want to use Angular 5 components inside razor views; those will be simple razor views and inside those, I will display some Angular 5 components. I've done this with ASP.NET Core 2, I changed the Outdir property to wwwroot in the file .angular-cli.json , and it worked, but I could not do it with ASP.NET

MVC bootstrap navbar not working after running NuGet updates

时光毁灭记忆、已成空白 提交于 2019-12-18 10:07:56
问题 An MVC app broke after we updated all the NuGet packages. After trying everything I created a new MVC app, updated the NuGet packages and the basic navbar... <div class="navbar navbar-inverse navbar-fixed-top"> <div class="container"> <div class="navbar-header"> <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse"> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class="navbar-brand" href="/"

No ASP.NET MVC 5 Web Application Template on VS 2012?

烂漫一生 提交于 2019-12-18 10:06:23
问题 I'm using Visual Studio 2012 and have just installed "Microsoft ASP.NET and Web Frameworks 2013.1 - Visual Studio". As expected, it added the option to create an "ASP.NET MVC 5 Empty Project" . The thing is, I see no way of jump-starting an already functional "base application" as I had when I was using MVC 4 (e.g. "Asp.NET MVC 4 Web Application" ). I only see an empty template. I've seen answers such as: How can I add the MVC 5 project template to VS 2012? Create and Run MVC 5 Project in VS

How does a new ASP.NET MVC 5 application know how to create a database and how does the Account Controller access the database?

爷,独闯天下 提交于 2019-12-18 10:03:28
问题 I created an ASP.NET MVC 5 Application using Visual Studio 2013 Update 2 . In the application, I have an Account controller. It's different from what I am used to and does not contain an instantiation of dbcontext . public class AccountController : Controller { private ApplicationUserManager _userManager; public AccountController() { } public AccountController(ApplicationUserManager userManager) { UserManager = userManager; } public ApplicationUserManager UserManager { get { return

How to sync model after using Code First from Database using Entity Framework 6.1 and MVC 5?

半腔热情 提交于 2019-12-18 10:03:18
问题 Assumptions Using EF 6.1, MVC 5, VS 2013, C# I have an existing database model designed in Toad DM for SQL Server and it's very important keep it always updated Steps and Notes Using ADO.NET Entity Data Model I chose Code First from Database ( new feature in EF 6.1 ) to generate the models. Note: Model classes and DbContext class generated successfuly but NO .edmx or .tt file was generated . Next I added a new scaffold item: MVC 5 Controllers with views, using Entity Framework. Note: Success,

Passive Attributes and Nested Containers

让人想犯罪 __ 提交于 2019-12-18 09:47:12
问题 Final Solution With help from @NightOwl888's answer, here's the final approach I went with for anyone who ends up here: 1) Added the global filter provider: public class GlobalFilterProvider : IFilterProvider { public IEnumerable<Filter> GetFilters(ControllerContext controllerContext, ActionDescriptor actionDescriptor) { var nestedContainer = StructuremapMvc.StructureMapDependencyScope.CurrentNestedContainer; foreach (var filter in nestedContainer.GetAllInstances<IActionFilter>()) { yield

How to correctly set foreign key constraint in one to many relationship in code first ASP.NET MVC 5 application

核能气质少年 提交于 2019-12-18 09:39:26
问题 So I have one document table and a ApplicationUser table. One user can upload multiple documents and a foreign key constraint has been applied accordingly using the code first approach. But the problem is, I am able to save the document without assigning the UserID foreign key id in the Documents table . What am I missing here? Below is my novice attempt. ApplicationUser Model: it's the standard model provided by the framework. Document Model: public class Document { public int Id { get; set;

Want to take difference between single series data and show them on chart in highcharts/highstock

这一生的挚爱 提交于 2019-12-18 09:38:41
问题 I am working on asp.net MVC 5 Referring to my question i want to take difference between each two points like this 2-1 3-2 4-3 5-4 and so on and then put them into my series data in chart Bellow is my controller code //Getting data from DB to view in charts SqlCommand Device_Id_command = new SqlCommand("Select Device_ID, Energy_kWh,Power_kW,Voltage_Phase_1,Data_Datetime,Voltage_Phase_2,Voltage_Phase_3,Current_Phase_1,Current_Phase_2,Current_Phase_3 from [ADS_Device_Data] where Device_Serial