Newest 'asp.net-mvc-5' Questions

Q&A for professional and enthusiast programmers

Making a modular MVC 5 project

I'm wondering about how to develop a really big MVC5 project with multiple modules. I have read about several patterns like using "RazorGenerator" and the "Areas"... but if the project is big enough, ...

client.DeleteAsync - include object in body

I have an ASP.NET MVC 5 website - in C# client code I am using HttpClient.PutAsJsonAsync(path, myObject) fine to call a Json API (the API is also mine created in Web API). client.BaseAddress = new ...

Quartz.NET triggers not working

In an MVC.NET project I want to use Quartz.NET to send an e-mail at a specific time every day. This is the code that starts the JobScheduler and is getting called in the Global.asax file on startup. I ...

MVC5 WebGrid export to excel with some columns readonly

I have a MVC5 webgrid, when the user clicks the actionlink the grid data is exported to excel, but four of my seven columns need to be readonly (unchangeable). How can I export my data and set the ...

Best way to prevent repetition of Validation annotations in VIewModel?

I have a Viewmodel with about 30 input properties with decimal regex validation ie: [RegularExpression(@"\d+(\.\d{1,2})?", ErrorMessage = "Invalid decimal")] public string strProperty { get; set; } ...

C# returning different types from function

I have written a following code which basically performs a JSON request towards my server: var client = new RestClient("mysite.com"); var request = new RestRequest(Method.POST); ...

Wait for form.submit() / POST to complete

I'm stuck in a really bizarre situation here. It's complicated to explain but I'll try my best. Detailed explanation of the issue: On every top Nav click (Green donuts/circles), or next button, I ...

No 'Access-Control-Allow-Origin' header is present on the requested resource. Error When calling WebApi

When calling WebApi from my other project I am getting this error. XMLHttpRequest cannot load http://localhost:64678/api/Employees/RetriveAllEmployees. No 'Access-Control-Allow-Origin' header is ...

How to make a link by helpers in ASP.NET MVC?

I'm new in ASP.NET MVC. I created a login form and created two text boxes, then I used requirements attributes for them that if the were empty or wrong make errors. Also I created a button link by @...

What is the difference between bundling feature in MVC5.0 and webpack bundling?

What is the difference in bundling feature between MVC5.0 and webpack bundling?

Share Resx Files between ASP.NET MVC and Azure WebJob

I've developed two projects with .NET Framework 4.6.1, one is a ASP.NET MVC 5 website and the other is a Console Application to be run on Azure as a webjob. I need to share the resource files between ...

How to append a Collection in JQuery FormData Object

I've a collection of Cards in my EmployeeMasterA class, I'm not sure what is the correct way to append the collection in FormData object. What I want something like this : var data = new FormData(); ...

Adding a list of items to a partial view

A little help for a new guy, and by new guy I mean programming intern in his second year of programming classes. I am working in asp.net MVC5. I have sales order page created and I am trying to add ...

Model is null, even though populated model is passed in MVC 5 view

I am using RedirectToAction to pass a new model to a different view. [HttpPost] public ActionResult Index(BlogViewModel vm) { vm.IsValid = ModelState.IsValid; vm....

Value of combo box selected not adding to the viewmodel

I am using MVC with kendo. A popup dialog opens on the click of the add button of the kendo grid. The modal dialog contains a fields including two comboboxes. I am populating the Viewmodel when the ...

How to use aggregate functions in linq with joins?

Hi I am writing linq query to get max count with columns from the two tables. I write sql query and it is below. select MAX(p.dispalyOrder) from NCT_Process p INNER JOIN NCT_Process_Settings s ON p....

Downloading HTML page in C# and loading it in memory fastest way

I have written a following code which downloads a page from a given URL: string html = string.Empty; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request....

Need to execute helper methods only once

I am creating a helper class for my MVC application. This class will contain static methods that will pull information the first time the user logs into the system. I have created two methods that ...

How to use ViewModel 2d array property in TextBoxFor?

I would ideally like to use 2d arrays with Textboxfor like below: @Html.TextBoxFor(model => model.Table[0,1]) @Html.TextBoxFor(model => model.Table[0,2]) However I believe it is not supported ...

An exception of type 'System.InvalidOperationException' occurred in EntityFramework.dll but was not handled in user code t

I am developing a website for the first time. I am facing an issue in connecting to database. This is an ASP.net mvc 5 web application. I am doing code first approach. On return View(db.Orders....

My Project was on asp.net mvc 4. now i update my mvc to 5. now these lines on view got underlined and are not recognizes

I think razor syntax is conflicting wih mvc 5. If somebody experiences such kind of problem. Please let me know Thanks. For errors screenshot:

ASP.NET MVC Datepicker Formatting display from model

I am using MVC 5 with Boostrap.Datepicker library from NuGet. My current datetimepicker is in the format of: format: 'YYYY-MM-DD hh:mm' It works fine for creating records and storing using dbcontext,...

Difficulty listing data using a view model in ASP.NET MVC

I am trying to pass data from a view model which derives from 2 models. The controller looks like this public ActionResult SessionDetails() { var Sessions = (from a in db.Appointments ...

i want to delete child record in jtable in asp.net mvc

i am using jtable in asp.net mvc. the parent entry is deleting but the child is not deleting .i have written this code also in when i am deleting parent .but in child it is not working . it is giving ...

Unity DI with MVC 5 in controllers

I'm currently having issues when trying to make a dependency injection inside a MVC controller. The current exception is the following: The current type, myproject.Core.ToolbarLogic, is an ...

How to save OAuth login details into database instead of solution using MVC

I am using OAuth to login for my MVC 5 project using gmail OAuth credentials. Its working fine but here i have to need save login data to database instead of .mdf file (Which was created automatically ...

How to get the File's Content Type in asp.net mvc 5

I know the file's name, that is saved on server, I want to get the contentType of that file that is saved on server, what I want is something like this: string loc = Server.MapPath("~/Content/Images/...

Pass Multiple values to ActionMethodSelectorAttribute

I am using ASP.Net 4.61, MVC5 I would like to catch Submit from 3 buttons in the same Action. I am using ActionMethodSelectorAttribute to catch which Submit button is pressed. It's working fine ...

Route issue with subfolder in Controllers

we have decided to use subfolders in our Controllers folder. All our controllers are working like they should, but for one reason or another it doesn't get in the Controller method when we add an {id} ...

Binding IEnumerable in ViewModel not working

I have a ViewModel - Customer. Within this there is an IEnumerable collection: public class Tag { public int TagNo{ get; set; } public DateTime CreatedDate { get; set; } } I output a list of ...

Generate dynamic colums in Grid.Mvc

I am doing MVC5 application. i use Grid.Mvc from CodePlex. At present my model is as follows. public string FormId { get; set; } public string Form { get; set; } public string ReturnType { get; set; ...

Routing issues with localization Html.ActionLink mvc 5

I have two links in my _Layout.cshtml @Html.ActionLink("French", ViewContext.RouteData.Values["action"].ToString(), ViewContext.RouteData.Values["controller"].ToString(), new { language = "fr" }, ...

Is it possible to stop ViewModel Decimal properties forcing “required” validation?

I have a viewmodel with a property defined like so: public decimal decProperty { get; set; } I have found this enforced "required" validation when I would like to allow nulls. To me specifying 0.00 ...

ASP.NET MVC: Can't register or login after the site has been hosted on azure

The site was working fine on the server and after I hosted it on azure. I can't login or register a new user... http://alibabastore.azurewebsites.net/ Where is the problem ? Please An error occurred ...

Alternative / Equivalent of “asp:SiteMapPath” in MVC 5

I'm searching for a control like the asp:SiteMapPath provided in WebForms in MVC 5. So far I have found some NuGet packages (like MvcSiteMapProvider) to achieve this... but is there a way to do it ...

Best way to control Error Message for decimal validation in ViewModel property validation?

I have a ViewModel property: public decimal decProperty { get; set; } I have found it difficult to customise the Error message for the above. However if I code the following, I can specify the error ...

Building a SPA from ASP.NET MVC Partial Views - Is it a good idea?

I've spent quite a bit of time with React and Redux and enjoyed it, but at times it has felt like overkill for line of business apps with lots of CRUD, but not huge amounts of state held in the ...

Is it possible to append complex JSON variable to FormData object

I'm developing an asp.net mvc 5 application, in which, I've performed a whole bunch of logic and iteration to get a huge data in a JSON object empdata. Now, I just want to append this empdata object ...

MVC 5 get value of CheckBox Checked in controller with Ajax.BeginForm

I use MVC 5 and I try to get the value of the checkbox checked in the controller but so far it always return null. Here is my code: In View @using (Ajax.BeginForm("Delete", "...

Token invalid on reset password with ASP.NET

I am trying to add the reset password functionality in my mvc web application. When I enter my e-mail address and submit the form I receive the e-mail that contains the token etc, then when I click ...

MVC Razor Engine Renderpartial View From Custom Location and also need to support fallback search location

I need to render the Partial view from Custom Locations but also want to support the fallback search location if custom location not found. How do I achieve this in MVC5. @HTML.Partial("~/Parent/...

SignalR 2.2.1 errors “Unrecognized user identity” if some custom data is updated in the FormsAuthentication Ticket

I am working on an MVC5 application that uses FormsAuthentication for user authentication. For some reasons (beyond my control), instead of the built-in sliding expiration, a custom approach has ...

Need to verify Autommaper implemented correctly in Asp.Net MVC

I have implemented Automapper in my MVC project but not sure if it is been done correctly. I am currently using Entity Framework Database First Approach and retrieving data using stored procedures. ...

Initialising list in the view model

I am implementing a viewmodel that would contain data from two or more models. The viewmodel is called UserProfileViewModel. Currently it has data from the Userprofile table. I would like to add ...

How to Update and Delete from multiple Tables (MVC 5)

I'm new to this mvc application I manage to insert data to multiple tables using view model and now i want to edit that data and delete it, I've been searching all the answers but still dont get it ...

Trying to implement a custom route in umbraco 7.5.3 but the overrided method FindContent does not get fired

I've trying to retrieve the rendermodel model into my custom hijacked method, but i always get null. The two optional parameters are correct. This is my custom route : RouteTable.Routes.MapRoute( ...

Mapping to complex type (Entity Framework) giving error

I am using Entity Framework database first approach. I am creating complex types for my stored procedure so that I can use it in my ASP.NET MVC application. I need to create the complex type as Entity ...

How to display multiple data from same table into a view in MVC5?

I'm trying to make this table into something like this I want to display information[1st Pic] from my table into a Container [2nd Pic] I want to make a dynamic view where the data can be edited by ...

Cannot build any VS project. Error: Failed to find a required export at runtime

As the title says, I have not been able to build any project today. This just started earlier today. I don't recall doing/installing/modifying anything risky. This is the output I get when I build ...

Should I use Ajax and Json data for CRUD operations in MVC 5 [on hold]

I have a simple MVC 5 web app with crud operations. I thought about using ajax and json data to perform all the crud operations, but I don't know if it will be the smart choice to do that. What are ...
Translating... 0%