asp.net-mvc-5

Users with different capabilities

无人久伴 提交于 2019-12-01 07:34:22
问题 I'm creating an ASP.Net MVC 5 application. In my website, 3 different types of users exist. Admin Normal users Restaurants Each of these users have its own capabilities and access rights. Meaning, the view for each of them should be different. I have created the models for both of the normal and restaurant. I was wondering how I can modify my existing structure to support this functionality. public class User : IUser { public User() : this(String.Empty) { } public User(string userName) {

Wait for form.submit() / POST to complete

*爱你&永不变心* 提交于 2019-12-01 07:06:01
问题 I'm stuck in a really bizarre situation here. It's complicated to explain but I'll try my best. Detailed explanation of the issue: On every top Nav click (Green donuts/circles), or next button, I must submit the form, if it exists and is valid. If not valid, form.valid() triggers validation errors and return false would stop any further propagation. This setup was working flawlessly until I noticed a strange behavior which isn't very persistence. Form on my 3rd tab, specifically, is quite

I can't seem to get a very basic cookie login example to work with MVC5 and OWIN

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-01 06:46:19
问题 I've been trying to get my feet wet with ASP.net MVC 5 for 2013, but so far I've failed to get even the most basic authentication working correctly. I've been reading around for the last few days and I finally stumbled upon (http://brockallen.com/2013/10/24/a-primer-on-owin-cookie-authentication-middleware-for-the-asp-net-developer/) which seemed to give the most basic simple example I could find. So I tried that, but it still fails to seem to actually create a session for the user. Here is

FileLoadException after installing Ninject.MVC5

独自空忆成欢 提交于 2019-12-01 06:39:13
问题 I am trying to learn ASP.NET MVC with Adam Freeman's "Pro ASP.NET MVC 5" book. Unfortunately all projects using Ninject throw the same error An exception of type 'System.IO.FileLoadException' occurred in Ninject.dll but was not >handled in user code Additional information: Could not load file or assembly 'System.Web.Mvc, >Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its >dependencies. The located assembly's manifest definition does not match the assembly

Asp MVC: How get roles from ApplicationUser

断了今生、忘了曾经 提交于 2019-12-01 06:34:43
问题 In ASP.NET MVC 5, in a controller, I have take the user that has make the request with: ApplicationUser user = System.Web.HttpContext.Current.GetOwinContext().GetUserManager<ApplicationUserManager>().FindById(System.Web.HttpContext.Current.User.Identity.GetUserId()); With the ApplicationUser instance, how can i get all the Roles of the user? 回答1: You can get user and assigned roles by using UserManager. var userManager = HttpContext.GetOwinContext().GetUserManager<ApplicationUserManager>();

StructureMap MVC 5 html.Action Issue

故事扮演 提交于 2019-12-01 06:27:59
I am trying to call an Action from my view using @Html.Action("ActionName","controllerName") . But my page fails to load with below error: A single instance of controller 'Web.Areas.Area1.Controllers.ActionController' cannot be used to handle multiple requests. If a custom controller factory is in use, make sure that it creates a new instance of the controller for each request. I am using structure map for Dependency injection. Please help me what am i missing. You need to add x.For<{Your controller name}>().AlwaysUnique(); in IoC.cs file. This should be done for every controller in your

Using ASP.NET Identity for a Role Provider easily

南楼画角 提交于 2019-12-01 06:26:15
I just spent the last two days researching and implementing the new ASP.NET Identity system with my existing database. More on that here: Integrating ASP.NET Identity into Existing DbContext . Now, I have a working UserStore and RoleStore , but I can't seem to figure out how to leverage them in my ASP.NET MVC 5 application without writing what seems like colossal amounts of code like in all the Identity samples that confuse me. There's two things I want to achieve: 1) use cookies to maintain the authorizations and 2) use roles to limit application access both in what is rendered in the views

Can't check in .mdf/.ldf in App_Data into TFS

亡梦爱人 提交于 2019-12-01 05:43:49
问题 I am working with ASP.NET C# MVC 5. .mdf/.ldf files in App_Data do not appear on Pending Changes in team explorer. Therefore I can't check them into TFS(visual studio online). I've tried recreating the project a few times and none worked. What might be the cause for this? 回答1: Go to Team Explorer and locate Excluded Changes and you should find it excluded. Right click the App_Data folder and include it. But you might want to reconsider including the database files. As you're developing and

Typescript files not compiling on Angular 2 with Visual Studio 2015

穿精又带淫゛_ 提交于 2019-12-01 05:37:25
问题 I followed Zach's Answer and create new VS 2015 .NET 5 project and run Angular 2 with Typescript. It looks like its working. But there is a little problem: MyApp.ts : import { Component } from "angular2/core"; @Component({ selector: "my-app", template: ` <div>Hello from Angular 2</div> ` }) export class MyApp { public constructor() { } } When i change the template, type some different text, lets say <div>Some text here</div> , and then i recompile the project and run in browser to see the

Setting Result in the context of ChallengeAsync method in an authentication filter

人走茶凉 提交于 2019-12-01 05:35:27
This question is related to the answer I have provided here . OP's comment got me thinking a bit. I suggested using a class implementing IHttpActionResult like this in the ChallengeAsync method of the authentication filter. public Task ChallengeAsync(HttpAuthenticationChallengeContext context, CancellationToken cancellationToken) { context.Result = new ResultWithChallenge(context.Result); return Task.FromResult(0); } public class ResultWithChallenge : IHttpActionResult { private readonly IHttpActionResult next; public ResultWithChallenge(IHttpActionResult next) { this.next = next; } public