Click here to Skip to main content
15,900,818 members
Everything / MVC / MVC4

MVC4

MVC4

Great Reads

by Sheshnath Kumar
This article will find out a solution to serialize/deserialize object by reference at server and client, also will serialize/deserialize objects having circular references.
by SEJohnson
Linking to an existing SQLDB in ASP MVC4.0 and EF5.x.
by Arora Sumit
Routing in MVC
by Dirk_Strauss
Securing Your .NET Applications – A Summary Review Of Visual Guard

Latest Articles

by Ejrr1085
This article describes two ways of how to create a multiple HTML select control in ASP.NET MVC programmatically, using JQuery, C# and Razor.
by Mahsa Hassankashi
Best approach for having more secure channel to transfer user information throughout the web
by Khademul Basher
How to create a set of data models from a set of database tables.
by Muhammad Albedewy
Validate Anti-Forgery in 6 easy steps

All Articles

Sort by Title

MVC4 

29 Mar 2014 by reshmatces
In Normal Asp.net We Write Code in !ispostback and write code in it server side...for example..private void Page_Load(object sender, System.EventArgs e){ if(!IsPostBack) { lstCity.SelectedIndex = 1; whetherIsGood = true; }}how to Establish...
29 Mar 2014 by Raul Iloc
The management of user actions MVC is different then in ASP.NET.Lets explain by using an example, supposing that from the user want to activate the Édit page by using a link or a button from Index page. 1.In response to the user action there must be a method in controller (that will be...
23 Jan 2022 by Member 15435636
When I try to add a view, an error message pops up saying "Arithmetic operation resulted in an overflow" What I have tried: I've unsuccessfully tried rebooting my PC, restarting and updating Visual Studio Community 2022
23 Jan 2022 by Member 10163600
I have the same problem with VS2022 Community. Released version. It's an MVC4 project.
23 Jan 2022 by M Imran Ansari
Quote: This issue already reported for fixation. Kindly open your Visual Studio in Admin mode to avoid this exception. I would suggests open as Admin by default. To open you Visual Studio in Admin mode, open VS installed folder. Right click on...
15 May 2020 by Member 13160027
I have to update list values with new values daily. the new value is listvalue+newvalue What I have tried: allPayouts = (from p in allPayouts where p.UserID == Paid.UserID select p).ToList().ForEach((p) => { ...
14 May 2020 by OriginalGriff
Compiling does not mean your code is right! :laugh: Think of the development process as writing an email: compiling successfully means that you wrote the email in the right language - English, rather than German for example - not that the email...
15 May 2020 by Richard Deeming
.ToList returns a List[^]. The list's ForEach method[^] executes a specified action for each item in the list. It does not return anything. Therefore, you cannot assign the return value (which doesn't exist) of that method to your variable. ...
27 Sep 2012 by tusDev1
Hi all,I am developing a MVC4 website for mobile (using Razor View Engine). I am having problem in creating postback. I have tried to put Input buttons on page using following code:@{ ViewBag.Title = "TestView";}TestView@using (Html.BeginForm("TestView",...
27 Sep 2012 by tusDev1
The solution was I created the new project and merged the code in new project & bingo It worked.But I couldn't findout the reason for that behaviour of first project.But anyway my project has started handling the post-backs.
2 Dec 2013 by Amol Lendave
I had created application in mvc razor view. In this CRUD operation's are thr.When i am going to submit form for creating User form it will give me required field message into validation summary. I also want to show errored input into red border but it wont apper becouse of...
10 Mar 2014 by Member 9579525
i am creating error log file while handling error using HandleErrror Attribute..but not all exceptions are saving in log file..i am also using try catch in my code.if we are handling errors in this way then can we use try catch or not..
10 Mar 2014 by Aravindba
Hai The best way to capture error using Try...Catch only,developer must use Try...Catch block in each function other wise code abort abnormally, i mean it user use website or windows application,if any error occur it goes to exception catch block and the show error message and continue to...
1 Oct 2012 by Sandeep Mewara
This is not a well framed question! We cannot work out what you are trying to do/ask from the post.
22 Jan 2014 by rushdy20
I am working on a mvc4.5 project where I am using the embedded id to create an image using the CaptchaHtmlHelperthe config file is as bellow ...
22 Jan 2014 by Christian Graus
Your error path is Requested URL: /secure/account/LanapCaptcha.axdIs that where it lives ? I think you need to start with a \ and specify the full path to the axd file, if that's not where...
23 Jan 2014 by rushdy20
issue was with the mvc routing. I have to put the routing as bellow routes.MapRoute( "RootPages_default", "RootPages/{controller}/{action}/{id}", new { controller = "Home", action = "Index", id = UrlParameter.Optional } );
25 Jun 2013 by Maddy_1008
Hello All,I am working on a task in that I want to import .bat file.And want to show .bat file content in multi-line textbox. User can edit that file content and user can again export that content as .bat file. For that I am using ASP.NET MVC,JQUERY. I have succeeded to import content...
25 Oct 2013 by Manish Kumar Namdev
Hi all,Can anyone suggest me which one of the architecture is best in use with its advantages and disadvantage.I know a bit about MVC but no idea for DNN(DotNetNuke) and Mojo.I looked at web but not getting specifically which architecture is most suitable for which type of project and...
28 Oct 2013 by thatraja
MVC is an architechture pattern. DNN & Mojo are CMS.Check these for comparisonASP.NET MVC CMS ( Thoughts, Reviews, Projects )[^]30 best ASP.net based CMS[^]
24 May 2016 by Sharma Ravi
Hi,My project is in MVC C# and sitecore. I need to implement 301 redirect if url doesn't contain https://www.mysite.com. If URL doesn't contain this domain url then I need to redirect with secure and www url. It should show in console. How can I do it. I have done it using jquery but it is...
24 May 2016 by F-ES Sitecore
Never do anything security related using javascript. Also why do you want to see something in the console? Anyway, you normally handle this using server-side code. Want you want to do is modify the httpRequestBegin pipeline and inject your own step. Create a class called...
24 Sep 2013 by ashok yede201
Hello,I am using third party Fileupload control to upload file by ajax call in mvc4.It works fine on local, but when I uploads website on IIS 7, it gives error 404 Not found.It searches for http:IpAddress:PortNumber/api/upload which is missing Virtual directory name from ajax call.My...
11 Sep 2012 by Ahamed Azeem
Hi,I have a @Html.DropdownList and i am populating it with data, but whenever postback occurs the selected value of the dropdown lost. How can i preserve the value of the @Html.DropdownList to preserve the value.Kindly help to resolve the issueregards
11 Sep 2012 by Kuthuparakkal
Try:http://stackoverflow.com/questions/6043642/how-to-preserve-dropdown-data-after-postback[^]
2 Apr 2014 by Kiran S. S.
Hi,I have list in Model. This list is having one selected value in it.When I am using @HTML.DropDownListFor, it is showing me the list but, it is not showing the selected value. Please help.
2 Apr 2014 by sankarsan parida
See this article and check your code you will get successhttp://peternewhook.com/2013/02/asp-net-mvc-selectlist-selectedvalue-dropdownlistfor/[^]
15 May 2016 by Mahesh@Dev
Beforeroutes.MapRoute( name: "Default", url: "{controller}/{action}/{id}", defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } );Afterroutes.MapRoute( "Default", "{action}/{id}", ...
16 Dec 2013 by OriginalGriff
Google is your friend: Be nice and visit him often. He can answer questions a lot more quickly than posting them here...A very quick search gave over quarter of million hits: Google: Types Of Filters in MVC4[^]In future, please try to do at least basic research yourself, and not waste...
6 Nov 2013 by Sampath Lokuge
I have written an article about Chat Application with SignalR. It contains Source code also. Check that.Chat Application with SignalR and ASP.net MVC 4I hope this will help to you.
18 Nov 2013 by ZurdoDev
There are many ways to do it including writing code, exporting manually, or using SSIS. I would recommend you decide on what you want to do and get started and if you get stuck on something specific then please come back and ask a specific question.
30 Jul 2014 by kutz 2
Hi all,Using MVC4 I am developing an application in which I want to display excel data in webgrid.When I browse an excel file using this application,it should display the excel data in webgrid.Anyone please provide a code for implementing the same.Thank you inadvance.
30 Nov 2014 by SrikantSahu
This is a simple application developed using C# MVC and jquery for basic CRUD operations. The application can be unit tested using selenium web drivers.
6 Jan 2016 by Member 10624821
This is my controller using System;using System.Collections.Generic;using System.Data;using System.Data.Entity;using System.Linq;using System.Web;using System.Web.Mvc;using C3CardKYC.Models;using System.Data.Entity.Validation;using System.IO;namespace...
8 Oct 2017 by David2509
hello i have to developpe a fuel products prices management system there are several prices with its formula that i have implemented and i have to calculate all this prices and store theme in database -price for domestic customers -prices for foreign customers -price for foreign regular...
8 Oct 2017 by F-ES Sitecore
1 There is rarely a "best" technology, but asp.net and mvc are certainly more than capable and a good option 2 It's up to you. These days people tend to use Entity Framework\LINQ as it's easier to do. Especially for simple operations like CRUD and basic queries so EF is probably a good option...
9 Mar 2018 by Muhammad Khan123049
In My Contact model having personId as foreign key when i update the model contact.A referential integrity constraint violation occurred: The property value(s) of 'Person.PersonId' on one end of a relationship do not match the property value(s) of 'Contacts.PersonId' on the other end.
15 Apr 2015 by Abhinav S
PersonId in Person table is a foreign key for the table Contacts.If you update Contacts with a PersonId that is not in the Person table, you are going to get this error.
1 Apr 2013 by Rohith Reddy Vadiyala
Hi,Can any one help me please. I'm struck in the middle of implementing JQueryGrid with Editable operation. At present I can able to display the records in grid but I need to perform Editable operations.this is my script code to display records: ...
8 Oct 2013 by Dirk_Strauss
Securing Your .NET Applications – A Summary Review Of Visual Guard
23 Aug 2013 by N_cooL
When I place [HttpPost] filter on Index action of my controller. I get error The resource cannot be found.Please any body explain me why is this happen. public class BooksController : Controller { public ActionResult Index() { return View(); ...
22 Aug 2013 by Bala Selvanayagam
HiIt looks for me that you are passing null value for the id parameter.Check this out and if you need further assistance, post me the routing config file contents and the action filter code segments
16 Dec 2013 by Member 10284209
About Global.asax File in MVC in Detail
6 Mar 2014 by Suraj Sahoo | Coding Passion
Global.asax is the heart of any application as it contains the protected void Application_Start() { AreaRegistration.RegisterAllAreas(); WebApiConfig.Register(GlobalConfiguration.Configuration);//it has configuration for Web Api template if you use in...
6 Mar 2014 by Ramug10
refer the below linkhttp://www.asp.net/mvc/tutorials/older-versions/controllers-and-routing/asp-net-mvc-routing-overview-cs[^]http://stackoverflow.com/questions/16884074/asp-net-mvc-application-error-handler-in-global-asax[^]http://www.dzone.com/articles/aspnet-mvc-4-where-have-all[^]
13 Oct 2014 by Member 11151776
Hello I want to show Text value of combo in listing but I don't know how to do plz help me in MVC 4 using EF.
13 Oct 2014 by nrgjack
here's an introduction of aspnet MVC on MVAhttp://www.microsoftvirtualacademy.com/training-courses/introduction-to-asp-net-mvc[^]there are different modules, take your time to learn before asking for help.when you'll finish the reading try by yourself and if you have problems ask a...
14 Oct 2014 by Suraj Sahoo | Coding Passion
Entity Framework MVC[^]Please go through the above link and learn. Then look below for answersSO Answers[^]If still you dont get your answer, then please post your code and comment back the queries. Will surely try help you .Thanks:)
5 Jan 2015 by dhage.prashant01
Hi friends, I have a partial view where in user can upload a file. following is my codePartial View:@model UploadeRateModel@Html.ValidationSummary(true)
5 Jan 2015 by dhage.prashant01
IE does not allow following:1. You cannot read the "value" of the element as it holds the filename.2. You can't fire up the file selection menu via JS.3. You can't fire submit of the file uploader control via JS.I was trying to do 2 point in following codeBrowseI just put the...
18 Aug 2014 by yadlaprasad
Hi All,Can you please help how to access properties defined in customfilterattribute in controller?public class TestFilterAttribute : ActionFilterAttribute { public bool IsAccessable { get; set; }TestController[TestFilterAttribute] public ActionResult...
18 Jul 2014 by Member 10956841
HiI am storing image in Database successfully.I want to display this image in Edit form to modify and save changes.but I'm just able to display image in Edit form. When i try modifying and save image in database this show following error.Access to the path...
5 Dec 2016 by Member 12325178
Hi Guys!Combobox in ASP.NET MVC4 without Entity Framework,Can anyone tell me how to use combobox for sending or retrieving data into database?I have a table of Student and Class. when i am creating the student then here Class_Id of ClassTable should be show in combobox.When I select the...
4 Dec 2016 by F-ES Sitecore
MVC is a presentation framework, it has no way of accessing databases itself so you can't add data to a database using MVC only, you're going to have to use some kind of database framework. If you don't want to use Entity Framework then use ado.net. Google "getting started with ado.net" for...
5 Dec 2016 by Saineshwar Bageri
If you are find how to get data from database for dropdownlist then here is exampleWhich might help youcreating-simple-cascading-dropdownlist-in-mvc-4-using-razorbinding-dropdownlist-in-mvc-in-various-ways-in-mvc-with-datafilter-grid-with-cascading-dropdownlist-in-mvc-using-razor
9 Jan 2013 by I.explore.code
Hi guys,I have just started out with ASP.NET MVC3/4 and I have hit my first wall. I have a model class and a view that is strongly typed to it and obviously a controller. This view has a WebGrid that defines several columns that are bound to the model and 2 date columns (text boxes...
17 Apr 2014 by gunjan k saxena
This tip will help to create an action filter to compress the contents like Json, partial view, etc.
9 Sep 2015 by Norbert F.D.
Hello.I want to create a user/password form and authenticate a user from Active Directory using ASP.NET MVC X.Lot of thanks.
9 Sep 2015 by Passion4Code
HelloAD Authentication[^]Please follow the article. Very nicely and precisely written.Hope it helps.Thanks
14 Sep 2015 by Norbert F.D.
Lot of thanks. But, I don't know why, but it doesn't works.Can you help me please?This is my code:Web.config
16 Apr 2019 by itsathere
I am new for Active Directory authentication. Need to create login using active directory. Please help me with explained example or link where i can learn to create active directory login
9 May 2016 by Nathan Minier
You'll want to switch from forms to windows authentication and deny anonymous users. This should open a login...
1 Mar 2016 by kbullit61
Newbie here.... I'm trying to build a simple page that would do a lookup from a users email address (attribute) from AD and check a group membership - validate the membership and then redirect - if not a member then redirect. Authentication would happen on the redirected app pages. User...
17 Aug 2016 by RAJU-11052090
i trying this but in output its simply displaying text not as dropdownWhat I have tried:var table = document.getElementById("tablett"); var ddlfront = ''; var ddlback = ''; //var...
27 Aug 2013 by Yustme
Hi,How can I add the [DataContract] attribute on TableEntity class which I don't have any influence on?[DataContract]public class MyClass : TableEntity{ [DataMember] public string Name { get; set; } [DataMember] public string Email { get; set; }}// I need...
27 Aug 2013 by Sergey Alexandrovich Kryukov
If the class is the base class, adding it to the contract is not enough, because how the serialization assembly can "know" about all the derived classes? You really need to add one more kind of attribute, System.Runtime.Serialization.KnownTypeAttribute, one per really used terminal derived...
8 Dec 2015 by ANTONY VIMAL
Is it possible to merge rows and columns dynamically based on our condition by using WebGrid. If possible how can i achieve it?TIA
9 Dec 2015 by Snesh Prajapati
Yes, you can merge rows and columns dynamically. First you need to get Id of row or columns. You can get it by inspecting element of WebGrid.Following links will you idea to achieve...
4 Oct 2016 by mayank.bhuvnesh
I am displaying data from database using a model. While displaying data I have added one more column with textboxes so that a user can input the quantity in that text box. After submitting the data I want that data to be stored in different table how can I achieve the.for ExampleI have a...
28 Aug 2016 by David_Wimbley
So to make sure I understand correctly.You have 2 models. Inventory and Orders. These models correspond to tables of Inventory and Orders as well?Since i don't see any code for your Action in your controller i'm going make one up.I'll first provide one of many possible solutions,...
4 Oct 2016 by RaunakGupta
when you already have quantity value when you are inserting that data into inventory table at same time you can also insert quantity value into order table. you don't need any viewmodel in this scenario.
19 Sep 2017 by Jaydeep Shah
i have list of user with time. i give orderby on time. now i want to append one more record at first position.but it add at last of list. What I have tried: selectedusr = roomList.Where(x => x.Username == hdnRoomName.Value).FirstOrDefault(); roomListtemp = roomList.OrderByDescending(x =>...
19 Sep 2017 by Graeme_Grant
List(T).Insert Method (Int32, T) (System.Collections.Generic)[^] roomListtemp.Insert(0, selectedusr);
23 Aug 2017 by Lodovico Guicciardini
For those that land here, if you are still struggling with this issue, know that the "Add fakes" option should be included with one of the updates of VS 2012 Premium. If you are facing a similar problem with a later version of VS, I would advice you to: -Check the edition, you'll need...
22 May 2016 by Maddy_1008
Hi Everyone,I have created twitter button and added below code to work it. Its working fine.Now I want to an image with this tweet. Any one knows, How to add image in tweet?Please tell me if any one have done this. $("#aTwitter").click(function () { var url =...
18 Dec 2013 by Zaheer A.M.
how to implement jquery datatable with filter, paging and sorting in asp.net mvc4
18 Dec 2013 by JoCodes
Refer the below link jQuery DataTables and ASP.NET MVC Integration - Part I[^]http://justinmichaels.net/using-jquery-datatables-with-asp-net-mvc-for-serverside-filtering-sorting-and-paging[^]Hope this helps you...
12 Sep 2013 by Anubhava Dimri
Hi Everybody,I have a Model Employee in which have two properties Id and EmpName. In EmpName have apply Required Validator and the Message i need to Display is"Please enter the Employee name of {0}".and the value of {0} should comes from the Model Id Field. Can anyone please...
12 Sep 2013 by Member 10271226
Hi,U should be using Custom Validation for that.Take a look at this link http://www.dotnetcurry.com/ShowArticle.aspx?ID=776[Custom Validation]
12 Sep 2013 by Anubhava Dimri
Hi Experts,I have a model Passenger in which have Fname Property in which have Required Field Validator and its error message. In error message having a parameter option where i want to send the Id field of Model. which is already having in model and view both.so please how can it...
12 Sep 2013 by Member 10271226
Hi, Probably u should be using custom validation for that.Here's a link http://www.dotnetcurry.com/ShowArticle.aspx?ID=776[Custom Validation]
8 Mar 2016 by Member 12345790
public UsersDBContext db = new UsersDBContext(); // GET: /UserMenu/ public ActionResult Index() { var dbContext = new UsersDBContext(); var userDetails = dbContext.Users.FirstOrDefault(userFirstName => userFirstName.FirstName == id); ...
21 Apr 2015 by Bhagyashree Chaudhari - Member 10473634
I want nodes like this way ,1) Dashboard2) Account 2a) Register 2b) Log off 2c) Test1 2d) Test2so i wrote below code , in Mvc.sitemap
27 Aug 2014 by Aashish vermaa
Hi,Can we add and edit record in MVC 4.0 using Entity Framework in a single Action and View?Please suggests me.Thank you,Regards,Ashish
27 Aug 2014 by uspatel
suppose you have two buttons on your UI ...
28 Aug 2014 by Pravuprasad
use "[HttpPost]" attribute and overload your action method and in view use a "button" of type "submitt".
28 Aug 2014 by Bhavik_Patel
this might work for you[HttpGet]public ActionResult Foo(FooModel model){ // do stuff}[HttpPost]public ActionResult Foo(FooModel model){ // do stuff}
31 Jan 2013 by Darith1974
I think i am doing this wrong, so please bear with me. I am working on asp mvc4 project. I want to add a entity framework to the project. So i presume i add it to the data models folder(it is generated from a database in my sql express). Now i want to create a DataAccess Class to read and write...
1 Feb 2013 by Darith1974
The solution is to ad the edmx to the models folder and use a code generator to generate the classes and data context. However now i have a new problem in that when i go to add a controller it does not see my data context?!
24 Jan 2016 by raddevus
This article extends the 2-part article I wrote showing you how to write your own blog engine in ASP.NET MVC.
12 Apr 2013 by Member 9984989
Hican you please write a code that allows a system user to enter tasks for an employee in the database, and in return the employee is able to view the tasks assign to them. Please provide Twitter bootstrap capabilities.Thank you!
13 Apr 2013 by Sandeep Mewara
It does not work like this here.Here is what is expected of enquirers:1. TRY first what you want to do! You may find that it's not that hard.2. Formulate what was done by you that looks like an issue/not working. Try them and tell if you face issues.Members will be more than happy...
13 Jun 2016 by chatarji
how to get the selected drown drop value from database..i'm storing employee details in one table with drop down selected value(integer) and in other table drop down value and text.my modelspublic class EmployeeDetails { public int empid {set;get;} public string...
31 Oct 2012 by Jeethu n.p
hi all ,, I want to add interactive elements like text box,text area,submit button into a popover in twitter bootstrap.js .this is my code ::: $(document).ready(function () { $("#example").popover({ content:...
29 Aug 2014 by Aashish vermaa
Hi,I need some help in the following seniors:1. I have a view page where I display around 10 records without using any filter condition. But after all the data bind on the page, user could search a particular record or filter record. How can I achieve this functionality using...
16 Sep 2015 by Vijaykumar Vadnal
Hello All,I am working on existing ASP.NET WebSite project(Not ASP.NET Web Application).I want to add MVC on top of my existing project. My current project which is designed by using ASP.NET 4.0.I do not want to add new MVC project in to the solution, wanted to mix the MVC along with...
16 Sep 2015 by Vijaykumar Vadnal
Hello All,I followed mvc 3 in asp.net website.However it works perfectly but only issue with this is I need to either enter complete controller url along with parameters if any or on button click server event I needed to give a controller call using Response.Redirect like...
26 Sep 2014 by MD SAJID sajid
I have few textboxes followed by webgrid. Textboxes like suppliername,age ,address.webgrid each consist of dropdown for category,dropdown for product,textbox for productvlaue and discount.now the problem is when click on save button,save action is getting called but the model fields are...
26 Sep 2014 by I will help you
Post SaveAction code please and View where you have SaveButton