asp.net-mvc-5

PagedList error: The method 'OrderBy' must be called before the method 'Skip'

↘锁芯ラ 提交于 2019-12-18 14:45:53
问题 Here's the full error message: The method 'Skip' is only supported for sorted input in LINQ to Entities. The method 'OrderBy' must be called before the method 'Skip' In the "PurchaseOrderController" I have added this code to the index method: // GET: PurchaseOrder public ActionResult Index(int? page) { return View(db.PurchaseOrders.ToPagedList(page ?? 1, 3)); } Also in the Index View for "PurchaseOrders" I have added this code: @using PagedList; @using PagedList.Mvc; @model IPagedList

MVC Contact Form with Email

淺唱寂寞╮ 提交于 2019-12-18 13:22:18
问题 I wonder if someone can please help with a MVC Contact Form which send an Email on submission? I think I have most elements setup, but for some reason the form appear to be sending (takes ages) then just returns back to the form and no email is received. MailModels.cs: namespace WebApplication1.Models { public class MailModels { public string Name { get; set; } public string Email { get; set; } public string Telephone { get; set; } public string Message { get; set; } } } Contact.cshtml:

MVC5: Enum radio button with label as displayname

我们两清 提交于 2019-12-18 12:55:34
问题 I have these enums public enum QuestionStart { [Display(Name="Repeat till common match is found")] RepeatTillCommonIsFound, [Display(Name="Repeat once")] RepeatOnce, [Display(Name="No repeat")] NoRepeat } public enum QuestionEnd { [Display(Name="Cancel Invitation")] CancelInvitation, [Display(Name="Plan with participants on first available common date")] FirstAvailableCommon, [Display(Name="Plan with participants on my first available common date")] YourFirstAvailableCommon } and I have a

Updating records using a Repository Pattern with Entity Framework 6

删除回忆录丶 提交于 2019-12-18 12:22:04
问题 I'm writing a simple blog application and trying to establish CRUD operations in my generic repository pattern but I'm getting an error on my update method that says: 'System.Data.Entity.DbSet' does not contain a definition for 'Entry' and no extension method 'Entry' accepting a first argument of type 'System.Data.Entity.DbSet' could be found (are you missing a using directive or an assembly reference?) I followed a post that explained how to 'fake' Entry() by adding additional level of

unable to configure Web API for content type multipart

匆匆过客 提交于 2019-12-18 12:16:29
问题 I am working on Web API's - Web API 2. My basic need is to create an API to update profile of the user. In this the ios and android will send me the request in multipart/form-data. They will send me few parameters with an image. But whenever i try to create the API, my model comes to be null every time. I have added this line in WebApiConfig also: config.Formatters.JsonFormatter.SupportedMediaTypes.Add(new MediaTypeHeaderValue("multipart/form-data")); This is my class: public class

Ajax.BeginForm doesn't fire AJAX script, falls back on postback

走远了吗. 提交于 2019-12-18 12:14:22
问题 I will update this problem with the solution, I wanted to include my problem and solution as I wasn't able to find it on Stackoverflow. If you want to jump in with the solution, feel free. I have a newly created 'Empty' MVC5 project created using Visual Studio 2013. I needed a from and wanted AJAX behavior if possible. Using Ajax.BeginForm was always straight-forward in MVC3 so I thought it would be in MVC5 also. However none of the javascript functions I've specified in OnBegin, OnFailure or

Getting and passing MVC Model data to AngularJS controller

巧了我就是萌 提交于 2019-12-18 12:11:42
问题 I'm pretty new to AngularJS and I'm at a loss here. Right now my MVC program uses Razor to display all the data in my .mdf database (i.e: @Html.DisplayFor(modelItem => item.LastName) ). However, I want to go mostly Angular. I am trying to use ng-repeat to display all of the Model data, but I am not sure how to pass that Model data to the Angular controller and then use it. I have tried serializing the Model to JSON in my ng-init, but I don't think I'm doing it right (obviously). Here is my

MVC5 project template for Visual Studio 2012

夙愿已清 提交于 2019-12-18 11:50:24
问题 I'd like to get started with ASP.NET MVC 5 using Visual Studio 2012. I've installed the "ASP.NET And Web Tools 2013 for Visual Studio 2012, but this "only" gives me an "Empty ASP.NET MVC 5 Project" template. For MVC4 web projects, I can select different kinds of Web applications (like "Standard", "Internet", "Intranet" etc.). And I've seen screenshots with similar options for Visual Studio 2013. Are there any project templates (for VS2012) which allow me to do the same for MVC5 applications?

Rotativa PDF generation working locally but not on IIS 7

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-18 11:41:42
问题 I have an ASP.NET MVC 5 application. It has a simple form and when the user submits it, the form is stored in the cache and then another controller action is called, this action will return the model as a view as a PDF. I have no need to save it locally, just to show it in the browser so that the user can download it. There is no need for a database either, that is why I store the model in the cache. Locally, on Visual studio 2013, it works fine. But when I publish it to IIS 7 I get an

mvc 5 SelectList from table with blank value for DropDownList

吃可爱长大的小学妹 提交于 2019-12-18 11:18:30
问题 I am using below code to create a drop down Controller ViewBag.Id= new SelectList(db.TableName.OrderBy(x => x.Name),"Id","Name") View @Html.DropDownList("Id", null, htmlAttributes: new { @class = "form-control" }) My question is how can I Modify SelectList to add a blank item so that there is a blank item automatically added for DropDownList . Thanks. 回答1: Use one of the overloads that accepts an optionLabel @Html.DropDownListFor(m => m.ID, (SelectList)ViewBag.MyList, "Please select", new {