asp.net-mvc-5

Complex Claim Values in .NET Framework with System.Security.Claims

只愿长相守 提交于 2020-01-01 02:39:09
问题 I'm developing a web app with Asp.Net 5 MVC, Owin and Oauth2 bearer token as auth type. Following this guide that adds a custom complex claim Json serialized to an instance of Microsoft.IdentityModel.Claims.ClaimsIdentity with success, I've tried to replicate the same example using the ClaimsIdentity on the System.Security.Claims namespace. Unluckily, it seems that adding a complexClaim to the ClaimsIdentity instance, the derived class type information is lost, and the claim is stored as a

Updating user role using asp.net identity

混江龙づ霸主 提交于 2020-01-01 00:34:28
问题 I have the following problem. While using the following code below to change the user's current role i am getting an exception with the message like below: [HttpPost] [ValidateAntiForgeryToken] public virtual ActionResult Edit(User user, string role) { if (ModelState.IsValid) { var oldUser = DB.Users.SingleOrDefault(u => u.Id == user.Id); var oldRoleId = oldUser.Roles.SingleOrDefault().RoleId; var oldRoleName = DB.Roles.SingleOrDefault(r => r.Id == oldRoleId).Name; if (oldRoleName != role) {

How to create dependency injection for ASP.NET MVC 5?

浪尽此生 提交于 2019-12-31 08:32:57
问题 Creating Dependency Injection with ASP.NET Core is fairly easy. The documentation explains it very well here and this guy has a killer video to explain it. However, I want to do the same thing with my ASP.NET MVC 5 project. How can handle dependency injection with ASP.MVC 5? Also, is Dependency injection limited to controllers only or can it work with any class? 回答1: In ASP.Net MVC you can use the .Net Core DI from NuGet rather than one of the third-party alternatives:- using Microsoft

How to create dependency injection for ASP.NET MVC 5?

时光毁灭记忆、已成空白 提交于 2019-12-31 08:32:57
问题 Creating Dependency Injection with ASP.NET Core is fairly easy. The documentation explains it very well here and this guy has a killer video to explain it. However, I want to do the same thing with my ASP.NET MVC 5 project. How can handle dependency injection with ASP.MVC 5? Also, is Dependency injection limited to controllers only or can it work with any class? 回答1: In ASP.Net MVC you can use the .Net Core DI from NuGet rather than one of the third-party alternatives:- using Microsoft

How to create dependency injection for ASP.NET MVC 5?

柔情痞子 提交于 2019-12-31 08:32:51
问题 Creating Dependency Injection with ASP.NET Core is fairly easy. The documentation explains it very well here and this guy has a killer video to explain it. However, I want to do the same thing with my ASP.NET MVC 5 project. How can handle dependency injection with ASP.MVC 5? Also, is Dependency injection limited to controllers only or can it work with any class? 回答1: In ASP.Net MVC you can use the .Net Core DI from NuGet rather than one of the third-party alternatives:- using Microsoft

Error renaming ASP.NET MVC project

倖福魔咒の 提交于 2019-12-31 08:07:31
问题 I have copied a previous project and renamed it. Once I had successfully renamed all the name spaces and it build correctly. I got the following error when I ran the application: The following errors occurred while attempting to load the app. - The OwinStartup attribute discovered in assembly 'User Manager Interface' referencing startup type 'User_Manager_Interface.Startup' conflicts with the attribute in assembly 'Service Monitor Web Interface' referencing startup type 'Service_Monitor_Web

project.Models.tableName:The field pvid must be a string or array type with a maximum length of '20'

╄→гoц情女王★ 提交于 2019-12-31 07:14:40
问题 I encounter exception error below when i try to add a new entry in the database with : db.patient_visit.Add(pv); db.SaveChanges(); An exception of type 'System.InvalidOperationException' occurred in project.dll but was not handled in user code Additional information: project.Models.tableName:The field pvid must be a string or array type with a maximum length of '20'. Before this, my model is automatically and originally set like below because i did Code-First migration with existing database.

Enum RadioButtonFor Editor Template set value

南笙酒味 提交于 2019-12-31 07:01:23
问题 Based on this question, I implemented a RadioButtonFor Editor Template. I works great but currently you cannot pass the value you want selected. EnumRadioButtonList.cshtml (Editor Template): @model Enum @foreach (var value in Enum.GetValues(Model.GetType())) { if ((int)value > 0) { @Html.RadioButtonFor(m => m, (int)value) @Html.Label(value.ToString()) } } I call it from View with: @Html.EditorFor(m => m.QuestionResponse, "EnumRadioButtonList") How do I pass the value QuestionResponse (enum)

Enum RadioButtonFor Editor Template set value

别说谁变了你拦得住时间么 提交于 2019-12-31 07:01:10
问题 Based on this question, I implemented a RadioButtonFor Editor Template. I works great but currently you cannot pass the value you want selected. EnumRadioButtonList.cshtml (Editor Template): @model Enum @foreach (var value in Enum.GetValues(Model.GetType())) { if ((int)value > 0) { @Html.RadioButtonFor(m => m, (int)value) @Html.Label(value.ToString()) } } I call it from View with: @Html.EditorFor(m => m.QuestionResponse, "EnumRadioButtonList") How do I pass the value QuestionResponse (enum)

Model is null while submitting the form in partial view in MVC5

ぐ巨炮叔叔 提交于 2019-12-31 04:08:08
问题 I am just trying to learn MVC and facing some issues.When I am submitting my partial view, I am getting null in Model Blog inside Create Method. What I am doing wrong and what is the right approach? View(Index.cshtml) @model IEnumerable<Samples.Controllers.Blog> @{ ViewBag.Title = "Index"; } <h2>Index</h2> <p> @Html.ActionLink("Create New", "Create") </p> <table class="table"> <tr> <th>Sample</th> <th>URL</th> <th>Name</th> </tr> @foreach (var item in Model) { <tr> <td> @Html.ActionLink("Edit