Posts

Showing posts with the label asp.net-mvc

Controller Doubled on URL (ASP MVC 2)

Controller Doubled on URL (ASP MVC 2) I have a form tag using Url.Action on my FormUser view: <form class="form-horizontal" action="..<%: Url.Action(ViewData("FormMode"), "Master") %>" method="post"> {some form code} </form> the ViewData("FormMode") is generated on my controller whether it's edit or create new. Here's my Master controller code: Function FormAddUser() As ActionResult ViewData("AreaMenu") = sideBarModel.createLineMenu ViewData("RoleOption") = RoleOption() ViewData("FormMode") = "i_AddUser" Return View("Form_User") End Function Function EditUser() As ActionResult ViewData("AreaMenu") = sideBarModel.createLineMenu ViewData("ReadOnly") = "readonly" ViewData("FormMode") = "u_UpdateUser" ViewData("RoleOption...

Claims lookup table

Claims lookup table In asp.net identity model there are the tables AspNetRoleClaims and AspNetUserClaims which contain the foreign keys RoleId and UserId respectively and also the columns ClaimType and ClaimValue. The question is why there is not a lookup table for the claims, a table which would contain Id and ClaimType or ClaimName and then we use a foriegn key for it in the tables AspNetRoleClaims and AspNetUserClaims? Why would that be a good idea? Claims can be anything, your table would be an intermediate step requiring maintenance. – bommelding Jul 2 at 8:35 In the current case, you would repeat the claim type with each user and role, you might mistype the claimtype when you write it many times. – malballah Jul 2 at 9:03 ...

OpenID Connect in ASP.NET - at_hash validation [closed]

Image
OpenID Connect in ASP.NET - at_hash validation [closed] I try to use OpenID Connect authentication against a well known IDP. I have tried from both ASP.NET and ASP.NET Core. Here is how I enable the OpenID Connect authentication in my ASP.NET Core 2.0 project: I get the same error in both projects: OpenIdConnectProtocolInvalidAtHashException: IDX21312: The 'at_hash' claim was not found in the 'id_token', but a 'access_token' was in the OpenIdConnectMessage, 'id_token' I see that the returned token does not contain the at_hash claim, but that should be ok since it is not mandatory. Is there a way to skip this validation? This question appears to be off-topic. The users who voted to close gave this specific reason:

Asp.net MVC5 - Object reference not set to an instance of an object.

Asp.net MVC5 - Object reference not set to an instance of an object. I'm training on Asp.net MVC5. and I did the follow. Model Name is Movie, with code as below., namespace mvc1.Models { public class Movie { public int Id { get; set; } public string Name { get; set; } } And a Controller with name 'MoviesConroller'. and a using statement "using mvc1.Models". public ActionResult Random() { var movie = new Movie() { Name = "Star Trek!" }; return View(); } And a View with name Random @model mvc1.Models.Movie @{ ViewBag.Title = "Random"; Layout = "~/Views/Shared/_Layout.cshtml"; } <h2>@Model.Name</h2> and this is the error i get Error By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the we...

Can't Connect to the table azure SQL in given DB connection using .net

Image
Can't Connect to the table azure SQL in given DB connection using .net My question is the Azure DB connection is working perfectly but when i use the sample Todo by given in the link https://docs.microsoft.com/en-us/azure/app-service/app-service-web-tutorial-dotnet-sqldatabase so i have already table in the database called "PhotoTable" but every time i run the sample (asp.net)it creates it own table ( Todoes table)in my DB ( DB is already i created and its connect fine with my existing DB) so the issue is its not connecting with mt table , i have done changing the controller and all other stuff , but it dosen't work, if anyone knows how to connect with existing table please kindly let me know , thanks ( if more information needed please let me know, i have added the screenshot of my table list and the table i need to connect i have highlighted with red) Did you give the right link? That link is about Azure Storage , but your question is abo...

Correct way to use AutoMapper in ASP.Net MVC

Image
Correct way to use AutoMapper in ASP.Net MVC I'm trying to start using ViewModels - but I'm having trouble with this POST not validating - the values in the model are shown in the Watch part below the code: ModelStats.IsValid = false My ItemViewModel is: public class ItemViewModel { public int ItemId { get; set; } [Display(Name = "Item")] public string ItemName { get; set; } [Display(Name = "Description")] public string Description { get; set; } [Display(Name = "Price")] public double UnitPrice { get; set; } [Range(0.00, 100, ErrorMessage = "VAT must be a % between 0 and 100")] public decimal VAT { get; set; } [Required] public string UserName { get; set; } } I'm sure it will be something simple - but I've just been looking at it so long, I can't figure out what I'm doing wrong. Can anyone please advise? Thanks, Mark The validation of the...

How to read JSON file from folder project ASP.NET

Image
How to read JSON file from folder project ASP.NET I create a folder "js" inside Script folder and create a file json with array citys and i try read this file on this folder and return a list to my select view. { "cidade": [ { "Nome": "Curitiba" }, { "Nome": "São Paulo" }, { "Nome": "Rio de Janeiro" }, { "Nome": "Santa Catarina" }, { "Nome": "Rio Grande do Sul" }, { "Nome": "Acre" }, { "Nome": "Goias" } ] } My class: public class Cidade { public string Nome { get; set; } } public class Cidades { public IList < Cidade > cidades { get; set; } } And my action : public class Cidade { public string Nome { get; set; } } public class Cidades { public IList < Cidade > cidades { get; set; } } This is the error: What is...