asp.net-mvc-5

ASP.NET MVC Developing a Layered Architecture

余生颓废 提交于 2019-12-19 11:32:34
问题 I am new to ASP.NET MVC and as of right now I have the basic understanding of how MVC works. I have created a simple mvc website which uses only one project utilizing the pattern Model-View-Controller. But I want to learn how to make an mvc web application that uses a specific architecture and having a hard time looking for references online to help me understand it. I was given a project, to study, and rewrite it but I don't want to be copying each classes one by one without understanding

How to Add new Row Dynamically in ASP.Net MVC 5

妖精的绣舞 提交于 2019-12-19 10:09:12
问题 I am looking for help on how to add a new row of LineItems to an Invoice in a create Razor view of an ASP.Net MVC 5 application. I have read almost all similar questions but none have addressed what I thought was a simple use case. Here is my Invoice model class public class Invoice { public int Id { get; set; } public int InvoiceNumber { get; set; } public List<LineItem> LineItems { get; set; } public Client Customer { get; set; } public DateTime DateCreated { get; set; } public decimal

OnValidateIdentity disables the MVC OWIN remember me option

断了今生、忘了曾经 提交于 2019-12-19 10:07:58
问题 When I activate the OWIN logout-everywhere feature via security stamps and use the OnValidateIdentity -Callback of the CookieAuthenticationProvider with the SecurityStampValidator -class, the user is logged out every time he closes the browser. provider.OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<MyUserManager, MyUser>( System.TimeSpan.FromSeconds(10),(manager, user) => { return user.GenerateUserIdentityAsync(manager); }); However, when I do the plumbing myself (lookup and

DateCreated and DateModified in ASP.NET MVC 5

℡╲_俬逩灬. 提交于 2019-12-19 09:32:01
问题 I am working on a Code-First project, and I need database to handle DateCreated and DateModified . The application is running on IIS Express with LocalDB on dev machine, and will be using SQL Server 2012 on deployment server with IIS 7.5. I have the following model: public class Person : IdentityUser { [Required] public string Name { get; set; } public Date DateOfBirth { get; set; } public string Address { get; set; } [DatabaseGeneratedOption.Identity] public Date DateCreated { get; set; }

Certain Razor views not publishing

喜你入骨 提交于 2019-12-19 08:11:56
问题 Using VS 2017 with MVC 5 Razor views. When I publish my application, a handful of specific views do not get copied over. I'd discovered several SE questions on this same issue from back in the 2010-2011 timeframe. At the time, the issue was that Build Action in the file's properties was not set to Content due to a bug in some early RC which has since been resolved. Well, all of mine already do day Content for Build Action. Any reason why only a small number of views are not making it in the

First external login attempt redirects back to login action, second one works

我与影子孤独终老i 提交于 2019-12-19 05:58:18
问题 I'm using OWIN's external authentication providers in my ASP.Net MVC 5 / WebApi 2 project and I've hit a strange problem. The login workflow is exactly like here on SO. User hits the login page, picks a provider and gets logged in. My problem is that the first click on a provider redirects back to the same login page: http://localhost:57291/Account/Login?ReturnUrl=%2fAccount%2fExternalLogin This would make sense if the ExternalLogin action would be lacking the AllowAnonymous attribute. When

Visual Studio 2013 button to add a View is disabled

╄→гoц情女王★ 提交于 2019-12-19 05:57:16
问题 After creating a few views, the AddView>Add button became disabled and I can't add views anymore. Does anyone have a hint about that? EDIT I can add views using the Add New Item command and selecting Views , but it's nonsense to me. 回答1: You may well have solved this by now, but I thought I'd add my answer for others suffering with this issue. This same issue happened to me, and the solution was to edit the .csproj file to tell Visual Studio that it was an MVC project. Here's what you do: 1)

Browser Link Visual Studio 2013 not working

血红的双手。 提交于 2019-12-19 04:57:19
问题 I am new to VS 2013 and recently got introduced to a feature called Browser Link. I think it's an awesome feature provided by microsoft. I am not able to get the connections. Following steps I did Created a new Empty MVC project Created a controller Home and Action Index Created a view Index.cshtml. Solution was in debug mode. Ran the solution. Following is the web.config settings for the project <?xml version="1.0" encoding="utf-8"?> <!-- For more information on how to configure your ASP.NET

ExternalLoginConfirmation returns null after facebook successful login

霸气de小男生 提交于 2019-12-19 04:51:19
问题 Implementing Facebook login in MVC 5 template, had added the app Id and secret code. Initially login was failing as it was returning null public async Task<ActionResult> ExternalLoginCallback(string returnUrl) { // Crashes on this line var loginInfo = await AuthenticationManager.GetExternalLoginInfoAsync(); if (loginInfo == null) { return RedirectToAction("Login"); } } After searching came across a solution which says to replace existing ExternalLoginCallback method with this [AllowAnonymous]

IdentityRole in multi-tenant application

北战南征 提交于 2019-12-19 04:44:14
问题 I am building an ASP.NET MVC 5 multi-tenant solution and have a slight problem when it comes to roles. I have created a custom role entity as follows: public class ApplicationRole : IdentityRole, ITenantEntity { public ApplicationRole() : base() { } public ApplicationRole(string roleName) : base(roleName) { } public int? TenantId { get; set; } } And done everything else needed.. it's all working nicely, except for one thing...; when a tenant admin tries to add a new role and if that role's