asp.net-mvc-5

Binding Viewmodel Property to dropdown selected item in razor

守給你的承諾、 提交于 2019-12-11 11:13:07
问题 public class State { public Guid Id { get; set; } public string Name { get; set; } } public class Address { public State State { get; set; } } public class JobSeeker { public Address CurrentAddress { get; set; } } public class RegisterVM { public JobSeeker JobSeeker { get; set; } public List<State> AllStates { get; set; } } in Razor @Html.DropDownListFor(m => m.JobSeeker.CurrentAddress.State, new SelectList(Model.AllStates, "Id", "Name" ), " -----Select List----- ") The result is the drop

How to handle nested collections in MVC 5

倖福魔咒の 提交于 2019-12-11 11:12:22
问题 I'm using MVC 5 and I want to have an edit page that allows selection of items from a list, with options for each item selected. So I have a model like this: public class TemplateEdit { public Guid TemplateId {get; set;} public string TemplateName {get; set;} public ICollection<MyOption> Options {get; set;} } public class MyOption { public Guid MyOptionId {get; set;} public Guid TemplateId {get; set;} public string OptionName {get; set;} public bool Selected {get; set;} public ICollection

Pass @Html.DropDownList selection using @Html.ActionLink with ViewModel to Controller

僤鯓⒐⒋嵵緔 提交于 2019-12-11 11:00:55
问题 I've been reading through posts for two days regarding this, and still have not figured out the answer. I want to capture the DropDownList selection within my ModelView, pass this to a @Html.ActionLink, which will send it back to a specific Action within the Controller. My ViewModel: public class ViewModelShipments { public ViewModelShipments() { tblShipments = new tblShipments(); } public tblShipments tblShipments; public IEnumerable<SelectListItem> ShipmentIDsList; public string

How Can I do this …Multiples models on view MVC 5

半城伤御伤魂 提交于 2019-12-11 10:56:40
问题 I want to do this view .. I have a model call Product Options and I need to bring on the view the name or photo path for different tables public class ProductOption { public int id { get; set; } [Display(Name = "Product")] public int ProductId { get; set; } [Display(Name = "Group")] public int GroupId { get; set; } [Display(Name = "Option")] public int OptionId { get; set; } [Display(Name = "Price")] public decimal priceIncrement { get; set; } } } This are the Product Model: public class

jquery trigger for submit form results infinite loop

别说谁变了你拦得住时间么 提交于 2019-12-11 10:48:36
问题 When starts my plugin it runs a trigger for loading data from mvc c# controller just once but the page is refreshing infinite (loop). When I press submit button is running ok. Here is the problem: if (opcoes) { $.extend(defaults, opcoes); $('#formPaginacao').trigger('submit'); } Rest of code (works when I press button submit): return this.each(function () { function postProcessing(data) { dados = data; p.totalRegistros = dados.length; defaults.totalPaginas = Math.ceil(p.totalRegistros /

In CQRS how to work with NServiceBus to update Command and Query store

若如初见. 提交于 2019-12-11 10:46:23
问题 In CQRS, how do you make sure a command handler is updating the write store and read store transactionally? I am not sure if these two steps are suppoed to be a transaction? Or do you rely on eventual consistency here? Meaning the read store will be updated eventually? What is the (or a) common way to do this using NServiceBus 5 or 6? In our application, we have IRepository<T> (Add, Update) for the command side to update Sql Server database. The query side is simple. A database and a facade

How to store token in mvc cookie and send it to api

老子叫甜甜 提交于 2019-12-11 10:42:30
问题 I am sending credentials to API which creates user then through MVC Login method i create token in Web API and return token in response to MVC now I want to store Token in MVC Cookie and again send it Web API when hitting API Controller authorized action. Please suggest me these two things 回答1: There's not a whole lot to work with here, but generally speaking, Web API diverges from MVC mostly in that it's fully REST-compliant, whereas MVC is not. REST-compliant applications are stateless (in

Passing IEnumerable property in RouteValues of ActionLink

最后都变了- 提交于 2019-12-11 10:31:58
问题 Imagine an object defined like : public class MyViewModel{ public List<string> MyList { get; set; } } In my view, i have this Action link : @Ajax.ActionLink("<", "Index", new MyViewModel() { MyList = new List<string>() {"foo", "bar"}}, new AjaxOptions()) The html result of the ActionLink will be : <a class="btn btn-default" data-ajax="true" href="/Index?MyList=System.Collections.Generic.List%601%5BSystem.String%5D"><</a> My question is, how get this result rather : <a class="btn btn-default"

Can I change asp.net mvc 5 identity user ID from string(GUID) to int

梦想的初衷 提交于 2019-12-11 10:29:51
问题 I wonder why asp.net mvc 5 Identity user uses string(GUID) as key not an int by default? Are there any reason to do this? I know that it is possible to change the key to int, but is this change good practice at all? May be this ids are kept somewhere in the cookie, or are used in OAUTH, and it is not recommended to do this? 回答1: Two things that come on top of my head are that int has a limitation where as GUID doesn't and that if I know my ID is 76, I can know the ids of at least 75 more

Role based tokens ASP.net Identity

早过忘川 提交于 2019-12-11 09:57:16
问题 I am using the standard ASP.net OWIN OAuth middleware system to authenticate local users with Bearer tokens. What I would like to do is is hand out role-based tokens for the same user account. eg. OAuth TokenA => General User Privileges UserA -> OAuth TokenB => Admin User Privileges Is this supported in any way? 回答1: I was able to solve this using the following method - //ensure the token is a User role token only identity.AddClaim(new Claim(ClaimTypes.Role, "User")); Where 'identity' is an