asp.net-mvc-5

Created a new view in MVC 5, opening the new view results in HTTP 404

拈花ヽ惹草 提交于 2019-12-01 19:04:20
When I open the default MVC views(index and create) it work fine, I can add data and get data from the database. When I create a new view it don't work. It gets Http 404. This is even if I duplicate the create view, only with a different file name. Error-message: Server Error in '/' Application. The resource cannot be found. Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly. I have follow some forum

Why I can't use HttpContext or HttpCookie? (Asp.Net Core 1.0)

匆匆过客 提交于 2019-12-01 18:44:59
问题 Why can't I use HttpContext or HttpCookie ? Is there a special using? My actual usings: using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; My namespace: namespace eCoffee.Main My class + methods: public class AppRunCookie { public static string CookieName { get; set; } public static string Key { get; set; } public AppRunCookie(string key) { CookieName = "MyCookie_" + key; } public static void SetCookie(string key, int cookieExpireDate = 30) {

The INSERT statement conflicted with the FOREIGN KEY constraint error

折月煮酒 提交于 2019-12-01 18:06:23
Hi I'm getting this error The INSERT statement conflicted with the FOREIGN KEY constraint "FK_dbo.AspNetUsers_dbo.Contacts_ContactID". The conflict occurred in database "aspnet-COGMakati-20140119015553", table "dbo.Contacts", column 'ContactID'. The statement has been terminated. I'm using Entity Framework and MVC 5's IdentityUser so I'm really lost on what I'm doing :| This is what I'm trying to populate: public class User : IdentityUser { [Required] [Display(Name = "First Name")] public string FirstName { get; set; } [Required] [Display(Name = "Last Name")] public string LastName { get; set;

Customised IdentityUserRole primary key

此生再无相见时 提交于 2019-12-01 17:58:23
I'm using ASP.NET Identity Provider and EF 6 Code First and I have created a custom IdentityUserRole table which has an extra column OrganisationId . The custom table is named UserRole. The table currently has the default primary key of UserId and RoleId . I would like to have the OrganisationId column included in the Primary Key of the IdentityUserRole table. I can see the UserRole table in my database, and it's the one that's being used for the userroles (there's no aspnet_userrole table and the table has data when I assign a role to a user) I tried this: modelBuilder.Entity<IdentityUserRole

MVC5 : Attribute Routing Precedence Among Controllers

送分小仙女□ 提交于 2019-12-01 17:38:27
I am using the Attribute Routing from MVC5 in my controllers. Question: Is there a way to control attribute routing precedence among controllers? Consider the following [Route("home/{action=index}/{username?}")] public class HomeController : Controller { [Route("home/index/{username?}", Order = 1)] [Route("home/{username?}", Order = 2)] [Route("{username?}", Order = 3)] public ActionResult Index() { // ... bunch of stuff } } Base on the code above, HomeController.Index() action method should be invoked using the following requests: domain/ domain/{username} domain/home/ domain/home/{username}

How to Authenticate using MVC5RC/RTW with existing database

淺唱寂寞╮ 提交于 2019-12-01 17:27:48
问题 I originally asked this question when Identity was in beta. The classes and interfaces have changed considerably since then and it appears the RTW version has some modifications again over the RC version. In principle I need to achieve the following. authenticate the local login against my usertable tblMembers which contains the userid field and password which are the two items I need to authenticate. have access to my tblMember record/class via the Controller.User property (Prior to MVC5

Authorize attribute not working MVC 5

非 Y 不嫁゛ 提交于 2019-12-01 17:08:05
I have separated the Models into Specific project After that MVC default [Authorize] attribute not working in my application When i try to login the application it is not login the application nor it is redirecting to the specific page Do you have something like this <authentication mode="Forms"> <forms loginUrl="~/Account/Login" timeout="2880" /> </authentication> in your web.config? Check if you have removed the forms authorization module. Some of the new templates remove forms authorization by default. If it has been removed, comment it out. It will look like this in your web.config:

GitHub Commit Error: Permission denied fatal: Unable to process path ~/App_Data/aspnet-MyProject.mdf

半腔热情 提交于 2019-12-01 16:55:43
I am attempting to commit an update to my ASP.Net MVC project using GitHub integration in Microsoft Visual Studio 2017. I am working on Code-First Migrations. After my previous successful commit, I performed the following commands on the Package Manager Console in Visual Studio: PM> Enable-Migrations -ContextType ApplicationDbContext PM> Add-Migration AccountNumberChanges PM> Update-Database -Verbose Once this was done, I tried perform a commit, but I was getting the following error: Git failed with a fatal error. error: open("MyProject/App_Data/aspnet-MyProject- 20171110110346.mdf"):

The INSERT statement conflicted with the FOREIGN KEY constraint error

…衆ロ難τιáo~ 提交于 2019-12-01 16:41:32
问题 Hi I'm getting this error The INSERT statement conflicted with the FOREIGN KEY constraint "FK_dbo.AspNetUsers_dbo.Contacts_ContactID". The conflict occurred in database "aspnet-COGMakati-20140119015553", table "dbo.Contacts", column 'ContactID'. The statement has been terminated. I'm using Entity Framework and MVC 5's IdentityUser so I'm really lost on what I'm doing :| This is what I'm trying to populate: public class User : IdentityUser { [Required] [Display(Name = "First Name")] public

Using MVC 5's identity, can't get user name right after logging in

我的未来我决定 提交于 2019-12-01 16:23:30
I'm trying to use the MVC 5's identity solution, but got stuck on something that should be very simple: I want the login method on the AccountController to get the loged user's name right after validating the model (and I don't want to use it from the model!). Here's a piece of my code: var result = await SignInManager.PasswordSignInAsync(model.Login, model.Password, false, shouldLockout: false); string NomeUsuario = ""; if (result == SignInStatus.Success) { NomeUsuario = User.Identity.Name; //<== getting the logged user's name } The problem that I'm getting is that this property is null.