asp.net-mvc-5

how to map composite key in CRUD functionality

五迷三道 提交于 2020-05-28 18:39:13
问题 I need to map based on two keys(comp and part). @foreach (var item in Model) { <tr> <td> @Html.DisplayFor(modelItem => item.comp) </td> <td> @Html.DisplayFor(modelItem => item.part) </td> ........................... <td> @Html.ActionLink("Edit", "Edit", new { id=item.comp }) | @Html.ActionLink("Details", "Details", new { id = item.comp }) | @Html.ActionLink("Delete", "Delete", new { id = item.comp }) </td> </tr> } how to use composite key in Index page and also in controller. public

Go To Controller shows “Unable to find a matching controller.” error

落爺英雄遲暮 提交于 2020-05-28 12:02:21
问题 In VS 2015, for my Web.API project, I installed MVC 5 from nuget via npm. This installation added references and generated web.config file under Views folder. I added new Controller with generated CRUD functions. When I right click and go to View on action it goes with no problem. But reverse action does not work. If I navigate to view via browser it works as well. Web app compiles as well. Is there any way for me to fix this navigation problem in VS? Did I forget to add something? Following

Accessing query string variables sent as POST in HttpActionContext

喜欢而已 提交于 2020-05-27 10:50:44
问题 I'm trying to access a query string parameter that was sent using the POST method (WebClient) to the Web API in ASP.NET MVC 5 (in an overridden AuthorizationFilterAttribute). For Get, I've used the following trick: var param= actionContext.Request.GetQueryNameValuePairs().SingleOrDefault(x => x.Key.Equals("param")).Value; However, once I use POST, this does work and the variable paran is set to null. I think that's because the query string method only applies to the url, not the body. Is

Accessing query string variables sent as POST in HttpActionContext

孤街醉人 提交于 2020-05-27 10:44:43
问题 I'm trying to access a query string parameter that was sent using the POST method (WebClient) to the Web API in ASP.NET MVC 5 (in an overridden AuthorizationFilterAttribute). For Get, I've used the following trick: var param= actionContext.Request.GetQueryNameValuePairs().SingleOrDefault(x => x.Key.Equals("param")).Value; However, once I use POST, this does work and the variable paran is set to null. I think that's because the query string method only applies to the url, not the body. Is

Accessing query string variables sent as POST in HttpActionContext

守給你的承諾、 提交于 2020-05-27 10:43:47
问题 I'm trying to access a query string parameter that was sent using the POST method (WebClient) to the Web API in ASP.NET MVC 5 (in an overridden AuthorizationFilterAttribute). For Get, I've used the following trick: var param= actionContext.Request.GetQueryNameValuePairs().SingleOrDefault(x => x.Key.Equals("param")).Value; However, once I use POST, this does work and the variable paran is set to null. I think that's because the query string method only applies to the url, not the body. Is

Accessing query string variables sent as POST in HttpActionContext

百般思念 提交于 2020-05-27 10:42:14
问题 I'm trying to access a query string parameter that was sent using the POST method (WebClient) to the Web API in ASP.NET MVC 5 (in an overridden AuthorizationFilterAttribute). For Get, I've used the following trick: var param= actionContext.Request.GetQueryNameValuePairs().SingleOrDefault(x => x.Key.Equals("param")).Value; However, once I use POST, this does work and the variable paran is set to null. I think that's because the query string method only applies to the url, not the body. Is

Check whether a char is null or empty in razor view

大城市里の小女人 提交于 2020-05-16 06:00:48
问题 It seems to be a fundamental question, but I could not find the exact answer. I am passing a null or empty char value ('\0' in c#) from Model to View, and in View I need to check whether the char is equal to null or empty. I have tried the following: if ("@Model.CharValue" != "\0") {...} if ("@Model.CharValue" != '\0') {...} if ("@Model.CharValue" != ' ') {...} None of them gave me the proper check. and using alert("@Model.CharValue"); The pop up gave me this character, which I have no idea

Create user programmatically using C# ASP.NET MVC Identity

百般思念 提交于 2020-05-15 10:56:28
问题 I'm trying to add a user programmatically to ASP.NET MVC Identity. The error I'm encountering is: UserManager threw an exception of type 'System.NullReferenceException' This function is called through a POST not originating from this site. It sits right below public async Task<ActionResult> Register(RegisterViewModel model) in the AccountController. [AllowAnonymous] public async Task<bool> GenerateUser(string email) { var user = new ApplicationUser { UserName = email, Email = email }; string

ASP.NET MVC - Taking search criteria as input, and displaying the results, in the same View

巧了我就是萌 提交于 2020-05-15 09:12:07
问题 In a single ASP.NET Razor view, I want to display 10 textboxes (the user will enter various search criteria into these), and then when the user submits the form and the server processes the action, I want to display the results in the same view (let's assume that there can be around a 1,000 rows that need to be displayed). Along with the results, I also want criteria textboxes populated with the values that the user had chosen previously (so that the user can modify the criteria if required

Display EditorFor() value as Read-Only on MVC View?

落花浮王杯 提交于 2020-05-14 19:56:49
问题 I have several fields I display on most of my views in my MVC5 Code-First app: [created_date] , [created_by] , [modified_date] , and [modified_by] . For the user, I would like to include these also on my Edit() view, but unlike my other fields I do not wish to have them editable (commonly created/by and modified/by data should NOT be editable). This is how I have the fields declared on my Edit() view currently: <div class="form-group"> @*@Html.LabelFor(model => model.created_date,