asp.net-mvc-4

Attempting ValidationAttribute in MVC4 that is asynchronous using Async, Task and Await

ⅰ亾dé卋堺 提交于 2020-05-15 03:35:25
问题 I am attempting to write a Validation attribute in MVC4. The purpose is to check for the existence of an application reference (just a string that represents a key I wish to prevent a duplicate for). My data is accessed via WebAPI and because I am using 4.5 I wish to make this asynchronous if possible. I am perhaps not making the best or appropriate usage of async and await but I would like to know how to call my async method from the overridden IsValid method of the inherited Validation

“Object reference not set to an instance of an object” when creating a new Web API controller with EF Scaffolding in Visual Studio 2012

旧时模样 提交于 2020-05-09 05:07:09
问题 I have an MVC4/Web API project, with an Entity Framework, Code First data model. When I try to create a new API Controller with read/write methods using a data context & model, I get an alert saying "Object reference not set to an instance of an object". I've done a bit of searching and found that some causes are incorrect project type Guids in the .csproj file, incomplete installation of the MvcScaffolding nuget package and one suggestion of installing Powershell 3. I have made sure all my

Dynamic filtering, sorting and paging on generic list with Entity Framework

北战南征 提交于 2020-05-01 12:15:12
问题 I am using jQuery datatable (http://www.datatables.net) in my MVC4 app and as you may know this table allows server side processing. I am going to use the table in multiple views tied to multiple controllers so I'd like to implement a generic way to filer, sort and page data without the need to write a method for each controller. If I were to do that, they would all look the same but they would target a different entity from the database and be doing textual filtering and sorting on different

React: Iterate over object, find array, and display array items

心已入冬 提交于 2020-05-01 07:10:29
问题 I'm trying to iterate over an object being return by the axios call to "/Home/NewsNotes". Response from Axios I'm able to display the property names to the screen, but I'm having issues accessing the "NewsNotes" array. Here's my code for my component. class ReleaseDetailsComponent extends React.Component { constructor(props) { super(props); this.state = { releaseNotes: {} }; } componentDidMount() { var _this = this; const urlParams = new URLSearchParams(window.location.search); const

React: Iterate over object, find array, and display array items

五迷三道 提交于 2020-05-01 07:07:54
问题 I'm trying to iterate over an object being return by the axios call to "/Home/NewsNotes". Response from Axios I'm able to display the property names to the screen, but I'm having issues accessing the "NewsNotes" array. Here's my code for my component. class ReleaseDetailsComponent extends React.Component { constructor(props) { super(props); this.state = { releaseNotes: {} }; } componentDidMount() { var _this = this; const urlParams = new URLSearchParams(window.location.search); const

Display Image [VARBINARY(MAX)] in MVC

人盡茶涼 提交于 2020-04-30 07:43:05
问题 I'm new to MVC. I got pictures stored in my table called "Resim". I want to see the pictures when I call the associated record from the view.I will use its id to call it. Here is my code of the controller: public ActionResult Details(int id = 0) { SozlukEntities db = new SozlukEntities(); KelimeTuru kelime = db.KelimeTuru.Find(id); if (kelime == null) { return HttpNotFound(); } return View(kelime); } Here is my code of the view: @model SozlukRG.Models.KelimeTuru @{ ViewBag.Title = "Details";

Is it possible to model bind a soap request with mvc?

梦想与她 提交于 2020-04-28 20:40:04
问题 A client has a service that sends out xml soap formatted requests that we need to receive via our .Net MVC4 project. A request would be in the format: <?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <soap:Body> <ReceiveStatusUpdate xmlns="http://test.com"> <StatusUpdate> <Reference>214563</Reference> <ThirdPartyReference>YOUR

Is it possible to model bind a soap request with mvc?

走远了吗. 提交于 2020-04-28 20:34:10
问题 A client has a service that sends out xml soap formatted requests that we need to receive via our .Net MVC4 project. A request would be in the format: <?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <soap:Body> <ReceiveStatusUpdate xmlns="http://test.com"> <StatusUpdate> <Reference>214563</Reference> <ThirdPartyReference>YOUR

ASP.NET WebApi form-urlencoded string deserialize

血红的双手。 提交于 2020-04-16 10:43:31
问题 I develop service with WebApi and Client which send to this service gzipped data by POST method (to save bandwidth). Both of them over my control. On server I receive compressed data, decompress It and have string such as: section[0][caption]=Foo& section[0][address]=175896& section[0][counters][]=2& section[0][counters][]=2& section[0][errors][]=ERR_NOT_AVAILABLE& errors=true& trmtimestamp=1346931864358 ie simple www-form-urlencoded string. Does ASP.NET MVC4 WebApi have some method to bind

How to render a partial view asynchronously

独自空忆成欢 提交于 2020-04-07 17:36:11
问题 Can a partial view be rendered asynchronously? I have a partial view that needs to render blog posts. The blog posts are returned asynchronously. In my _Layout file I render my partial footer _Footer . In _Footer I have the following markup: @Html.Action("FooterLatestBlogPosts", "Common") So in my Common controller I have the following action method: public async Task<ActionResult> FooterLatestBlogPosts() { List<ArticleDTO> articleDTOs = await articleTask.GetAllAsync(); return PartialView