asp.net-mvc-5

RequireUniqueEmail = false not working MVC 5

心不动则不痛 提交于 2021-02-10 10:54:20
问题 I'm developing a MVC 5 solution where I can manage "Organizations" and users can register under them. I implemented the account controller to get the Organization ID from the register form and save it inside the AspNetUsers table. Now I know which user belongs to which organization. But now I have a problem, each time I try to register an user using the same email registered to another organization I get the message: "Name t@t.com is already taken." Do you know how to make ASP.NET Membership

Asp.net MVC 5 MapRoute for multiple routes

爱⌒轻易说出口 提交于 2021-02-09 10:56:38
问题 I have 3 routes in RouteConfig: routes.MapRoute( name: "ByGroupName", url: "catalog/{categoryname}/{groupname}", defaults: new { controller = "Catalog", action = "Catalog" } ); routes.MapRoute( name: "ByCatName", url: "catalog/{categoryname}", defaults: new { controller = "Catalog", action = "Catalog" } ); routes.MapRoute( name: "ByBrandId", url: "catalog/brand/{brandId}", defaults: new { controller = "Catalog", action = "Catalog" } ); and this is my action controller receiving parameters:

Passing a model to a partial view

我的未来我决定 提交于 2021-02-08 06:19:41
问题 I have an _Address partial view. This partial view contains all of the address fields that match the Address Model. At the top of this view I set the model like this: @model Data.Address In my CustomerInfo view I try the following to render the Address fields as part of my form: @Html.Partial("~/Views/Shared/Partial/_Address.cshtml") The error I am getting is: The model item passed into the dictionary is of type 'Data.Customer', but this dictionary requires a model item of type 'Data.Address'

Asp.Net Mvc 5 image not displaying

风流意气都作罢 提交于 2021-02-07 20:02:19
问题 I have same images in Content and Views folders. I am trying to display images as below: <img src="~/Content/Images/download.png" alt="Content folder" /> <br /> <br /> <img src="~/Views/Home/download.png" alt="Views folder" /> <br /> The image in Content folder displays successfully but the one in Views folder doesn't display and gives below error: Failed to load resource: the server responded with a status of 404 (Not Found) But actually, the resource is there. Here are my folders: Could you

Asp.Net Mvc 5 image not displaying

泪湿孤枕 提交于 2021-02-07 20:00:24
问题 I have same images in Content and Views folders. I am trying to display images as below: <img src="~/Content/Images/download.png" alt="Content folder" /> <br /> <br /> <img src="~/Views/Home/download.png" alt="Views folder" /> <br /> The image in Content folder displays successfully but the one in Views folder doesn't display and gives below error: Failed to load resource: the server responded with a status of 404 (Not Found) But actually, the resource is there. Here are my folders: Could you

Difference between authentication and authorization filters in aspnet-mvc5

巧了我就是萌 提交于 2021-02-07 14:27:24
问题 Why authentication filter is included in mvc 5? What is the major difference between authentication filter and authorization filter in mvc 5? 回答1: I found the following blog post: ASP.NET MVC 5 Authentication Filters Basically its about separation of concerns. Authentication: find out WHO issued a request. Authorization: find out whether a known user is allowed to perform a certain action. 回答2: To answer this you must understand the difference between authentication and authorization . Simply

Difference between authentication and authorization filters in aspnet-mvc5

守給你的承諾、 提交于 2021-02-07 14:26:11
问题 Why authentication filter is included in mvc 5? What is the major difference between authentication filter and authorization filter in mvc 5? 回答1: I found the following blog post: ASP.NET MVC 5 Authentication Filters Basically its about separation of concerns. Authentication: find out WHO issued a request. Authorization: find out whether a known user is allowed to perform a certain action. 回答2: To answer this you must understand the difference between authentication and authorization . Simply

MVC 5 Routing with parameter using @Url.RouteUrl

生来就可爱ヽ(ⅴ<●) 提交于 2021-02-07 10:45:51
问题 I have an ActionResult that I have applied a routing attribute to: [Route("myproduct/{productID}", Name = "myproduct")] [MvcSiteMapNode(Title = "Products", ParentKey = "products", Key = "myproducts")] public ActionResult myproducts(int productID) ... I am trying to link to the view via a RouteUrl: <a href="@Url.RouteUrl("myproducts", @Model.myproducts[i].productID)">Buy</a> The resulting html does not even include a href: <a>Buy</a> If I remove the parameter it works: [Route("myproducts",

JSON Objects are serialized to empty brackets when returned using JsonResult

瘦欲@ 提交于 2021-02-07 10:20:20
问题 I am operating in the .NET Framework using ASP.NET MVC 5. I have an MVC Controller that is using Newtonsoft.Json (or json.net) to build a nice JSON object. The trouble I'm running into is that when I return my json using the JsonResult method Json(JSONdotnetObject) , I end up with a result that has the same structure as what I would expect but everything is empty JArrays like so: Expected: { "prop": { ... some stuff ... }, "another prop": { ... more stuff ... } } Actual: [ [ ... empty ... ],

JSON Objects are serialized to empty brackets when returned using JsonResult

↘锁芯ラ 提交于 2021-02-07 10:19:20
问题 I am operating in the .NET Framework using ASP.NET MVC 5. I have an MVC Controller that is using Newtonsoft.Json (or json.net) to build a nice JSON object. The trouble I'm running into is that when I return my json using the JsonResult method Json(JSONdotnetObject) , I end up with a result that has the same structure as what I would expect but everything is empty JArrays like so: Expected: { "prop": { ... some stuff ... }, "another prop": { ... more stuff ... } } Actual: [ [ ... empty ... ],