Click here to Skip to main content
15,891,657 members
Everything / MVC / MVC5

MVC5

MVC5

Great Reads

by raddevus
Part 1: Master the ASP.NET MVC Project Template & Technologies (Razor, jQuery, JavaScript, Bootstrap, CSS). Part 2: Build an ASP.NET MVC app which runs in the browser but feels like using a desktop app.
by Mostafa Asaduzzaman
Simple Message/Reply app using MVC 5
by Simon B.
How to localize an ASP.NET MVC application and read all text from a database while still using DataAnnotations.
by kannankeril
This article is an attempt at splitting out the controller layer to reduce its complexity and improve quality and maintainability of the resulting code.

Latest Articles

by Shaurya Servegar
How to implement Custom RouteHandler and Custom Handler in ASP.NET MVC 5
by Saineshwar Bageri
In this article, we are going to learn how to implement the best Logging libraries available in the market for an ASP.NET MVC application.
by Yogi S.
Tutorial on implementing OpenWeatherMap API in ASP.NET MVC. It will teach how to get real time weather data of any city of the world.
by Proneetkumar Pradeep Ray
JQuery Datatable (Dynamic columns) populate after Ajax JSON response via server side processing - Using EF Raw SQL query

All Articles

Sort by Title

MVC5 

20 Feb 2016 by Abrar Kazi
"return Json(true,JsonRequestBehavior.AllowGet)" returns 'true' on screen instead of calling Onsuccess MethodI am calling Action method from Ajax.BeginForm("ActionMethod",new AjaxOptions{OnSuccess="MyScript",HTTPMethod="POST",OnFailure="MyScript2"})What I have tried:I tried...
15 Feb 2016 by Manas_Kumar
Follow below steps to implement AJAX.BeginForm in MVCStep1: Enable Unobustrive in web.config Step2: Add following code in your view page(*.cshtml)@using (Ajax.BeginForm("PerformAction", new AjaxOptions { OnSuccess = "OnSuccess", HttpMethod="POST", OnFailure =...
2 Apr 2020 by Richard Deeming
The "A" in "AJAX" stands for "asyncronous". That means the code doesn't wait for the $.ajax call to complete before it continues. Your success callback will be called once the request has completed, but that will be after the modal is shown. ...
2 Apr 2020 by TCS54321
i am new in AngularJS. i need to show some details in modalpopup by click on button in table row. My table code is :- {{data.OrderNo}} ...
13 Sep 2018 by Member 12857417
Using Kendo UI in HTML helpers or Extensions[^]
30 Mar 2015 by star_tasneem
want to dynamically populate dropdownlist. have table of District{district_id,distrint_name} and Thana{thana_id,thana_name,district_id(fk)}.The controller code:public class CenterController : Controller { string connection...
14 Aug 2018 by Niranjan Vinay
If the pass the registered email id and password to login it's showing the error. There is Exception thrown in entityframework.dll and Repository.dll What I have tried: I have tried deleting .vs folder. Tried cleaning the source and rebuild it.
10 Dec 2017 by Member 13507572
I am trying to pass valued from my database to a shared view but I keep getting this error (Please note I am very new to MVC, so I dont understand the error I get) - The model item passed into the dictionary is of type...
18 Jan 2017 by Bart-Jan Brouwer
.Net Core datagrid with server side paging, sorting and filtering
22 Oct 2020 by listojay
Im having trouble disabling or set textbox to readonly after postback submission.what code do i need from controller to disable a razor textbox in views.please dont suggest to use jquery for me to familiarize mvc thanks.What I have tried:i can do this by default but cant control the...
23 Oct 2016 by F-ES Sitecore
MVC is a server-side technology, you can't use it to dynamically amend the DOM in the browser, so I'm afraid you're going to have to use javascript or jQuery to do this.
22 Oct 2020 by Member 14972759
Solution by ROCH DEVELOPER @Html.EditorFor(model => model.Consecutive, new { htmlAttributes = new { @class = "form-control", @Value = ViewBag.Consecutivo, disabled = "disabled" } })
29 Jul 2015 by Sachin@100
@using (Html.BeginForm("View1", "Login", FormMethod.Post)){ @grid.GetHtml( htmlAttributes: new { id = "gridT", width = "1200px" }, columns: grid.Columns( grid.Column("systables.tabname", "Table...
29 Jul 2015 by Sachin@100
2. I am having 2 webgrids , when i check the rows of a first grid then it delete and moves on to the second grid. and when i check the rows of a second grid then it delete and moves on to the first grid.
29 Apr 2019 by TheBigBearNow
I have 2 buttons but I cant bring my model to the page and click a button to determine how to set my model. I’m thinking if I can get my model in my page I’ll be able to figure out these buttons possibly. I tried bring the model like usual new { model = Model} but my model Is still null… Here...
25 May 2016 by Member 12385326
i want to fill two textboxes from database on the seletion of dropdownlist.What I have tried:can anyone give me demo on this question. i am stucking here.i tried my best.but not getting output.
25 May 2016 by Karthik_Mahalingam
try thispublic ActionResult GetValuesFromDatabase(string inputId) { int inputid = Convert.ToInt32(inputId); using (AccountDBEntities2 acc = new AccountDBEntities2()) { var item = acc.tbl_CustomerCreation.FirstOrDefault(k => k.Account_No...
28 Sep 2016 by manish-gusain8909
what is the difference between 3tier architecture and mvc . and can use 3 tier architecture in MVC.kindly suggestWhat I have tried:i have worked on 3 tier architecture. and beginer in mvc can use 3 tier in mvc. what are the advantage and disadvantage
28 Sep 2016 by F-ES Sitecore
That's like comparing apples and oranges. MVC is a presentation framework that separates the various parts of displaying the data (into model which represents the data, the view which shows it and the controller which is the interface between the two) whereas 3tier architecture allows you to...
3 Apr 2016 by suhel_khan
I have several URLs which I need to transfer to domain name. I have tried through code but I am getting two 301 redirects. My requirement is to simply redirect below URLs to...
10 Oct 2017 by xXxRevolutionxXx
I am creating a ASP.NET MVC web site and as the title say i am trying to send a POST request to Web Api controller with jquery, but am always receiving a 404 error. The crazy thing is that in the .NET framework 4.5 the exact the same thing worked, but in the .NET framework 4.6.2 it really...
6 Sep 2017 by Graeme_Grant
404 is "page not found". You are looking for a route that does not exist. As "j snooze" mentions, as part of the debugging of routes, try it manually. Also, use the Web Browser debugging tools and check the actual raw conversation to see if the URLs being called are in fact what your route table...
6 Sep 2017 by koklimabc
$.ajax({ url: "/api/cart", type : "Post", data: $(this).next().val() }); window.location.href = "~/Login/Account"; Backend code private ApplicationDbContext _context = new ApplicationDbContext(); private...
10 Oct 2017 by Bryian Tan
Did you check the Cross-Origin Requests (CORS) setting? I'm guessing, this is the error the application is throwing when invoking the API through jQuery AJAX request. HTTP404: NOT FOUND - The server has not found anything matching the requested URI (Uniform Resource Identifier). XHR OPTIONS ...
29 Dec 2017 by #realJSOP
I have a partial view in which I am passing a model (the model object is not null). This is the method in the controller: [ChildActionOnly] public ActionResult LargeHeader() { PWQuote quote = db.GetRandomQuote(-1); return PartialView("_LargeHeader", quote); } When I try to use the...
21 Aug 2016 by manjiriV
it will be heplful if some one can tell where from this "model => model.StateName" is comming and also about htmlAttributes: new { @class = "control-label col-md-2" } auto generated in .cshtml file using entity framework@Html.LabelFor(model => model.StateName, htmlAttributes: new { @class...
21 Aug 2016 by njammy
The following line:@class = "control-label col-md-2"is "bootstrap" selectors. (bootstrap.css stylesheet classes)"model => model.StateName"...this is a property on the model object. Your model object class will be defined at the top of the cshtml as "@model myModel" or something...
11 May 2016 by Member 12512746
Hello! I have a problem with sending objects (as hidden) to the controller for it to operate with them.I have a table that has hyperlinks in its first column's values. I want to call a method which recives the object of that row, but I dont want that user to see the object. How can I achieve...
11 May 2016 by Strikerzz Arut
Hi,I think you can serialize and de-serialize the object to get the desired output.convert an user-defined object to the javascript option using Json.Enocode(Item)Then pass the object to the controller using the ajax function call.
18 May 2014 by Shahriar Hossain
[Attribute] Routing in ASP.NET MVC 5 / WebAPI 2
16 May 2017 by Member 13203697
Dear All! I am new to asp .net mvc. I have made a project in asp .net mvc. When hosted my project on uniquelinks shared web hosting panel I got this exception.Please help me to resolve it. Thanks in advance. What I have tried: I have googled it and applied some solutions like change in web i.e...
16 May 2017 by Richard Deeming
As the exception says, you need to change your AppPool from the "classic" (IIS6) mode to the newer "integrated" (IIS7) mode: Moving an ASP.NET Application from IIS 6.0 to IIS 7.0[^] If you can't find how to make that change in your web hosting panel, then you need to contact the hosting...
19 Apr 2016 by Member 12471471
i have used CRUD for:parcel type, weight, delivery area, collection area, delivery type, width, height, length, vat and quantity.all those tables above, i have created eg:public int typeID {get;set;}public string typeName {get;set;}public double typePrice {get;set;}outcome:...
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...
4 Dec 2017 by Subhash Tripathi
I want to convert html to pdf in mvc . for this i am use Abcpdf converter .i am use following code but its gives error ""Unable to render HTML. Unable to load page. (HTTP 403)." . Every time we i run this following line gives error and brake execution " theID =...
4 Dec 2017 by Jochen Arndt
See HTTP 403 - Wikipedia[^]. AbcPdf is not a web browser. It might not work as such regarding redirections which are used by the Yahoo URL from your example. If you type that URL in your browser, you will notice that there is a redirection (in my case to "https://de.yahoo.com/?p=us"). You can...
4 Apr 2014 by Shrikanth G S
i have a ajax action link button like below@Ajax.ActionLink("View Document", "ViewDocument","Property", new RouteValueDictionary { { "id", ViewBag.DocumentName } }, new AjaxOptions{ HttpMethod="GET", ...
14 Dec 2016 by Member 12308494
abp boilerplate ASP.Net MVC , showing error AuditingInterceptor.cs not foundWhat I have tried:[AbpAuthorize(PermissionNames.Pages_Tenants)] public async Task CreateTenant(CreateTenantInput input) { //Create tenant var tenant =...
14 Dec 2016 by Dave Kreskowiak
Why are you asking us, a bunch of people who have never heard of ABP Boilerplate?Ask in a forum dedicated to the library you're using, here[^]. See that little "Forum" link at the top of the window? Click it and ask your question in there.
7 Sep 2016 by Vignesh Mani
Hi, How to give access permision to Network path from web server to file server in IIS?What I have tried:I am accessing network path to download files from web server to file server but it is showing some prvillage error.
7 Sep 2016 by F-ES Sitecore
You need to run your site's code under an account that has the desired permissions to access the network share. This will explain how you change the account the code runs underApplication Pool Identities : The Official Microsoft IIS Site[^]If no suitable account exists then you'll need...
7 Sep 2016 by Gamecryer
Thanks for the help. I was stuck and this saved me
3 Jun 2015 by Grant Weatherston
I have a DataTable object, that i'm using to represent data in a view. The view is generic and therefore i want to just pass in data and display it on the page for all my models (rather than having a different view for each model, when all going to look the same visually).My problem is, i'm...
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...
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...
22 Apr 2015 by Member 11588640
I have a basic key value table from a SQL Server Local DB. I would like to add a checkbox which expands (and contracts) the table if selected/unselected.Start:Add Prices With Sides: [unchecked checkbox]Pancakes: $4.00Waffles: $5.00Add Prices With Sides: [checked...
27 Jun 2023 by Akshay malvankar
I have one datable consist around 25000 record datable look like this Id Name Lname bday 1 abc hdhd 25-02-1991 2 cnd dhdhd 7-05-1995 3 dhdhd ddjd 15-07-1993 4 dhhdd ddddhd 05-09-1999 i am converting above...
27 Jun 2023 by OriginalGriff
This is your 49th question, pretty much all of which can be answered with a trivial google, or a little knowledge of the classes you are playing with. In this case, it's simple to work out what you need to do by thinking about a DataTable and...
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.
1 Apr 2016 by ErBhati
Hi experts, I want to add google calendar for event same as google contact in my mvc applicationmy need is i have a textbox for date and a button for add this date to google calender. and i have no idea how i implement this. if any one has the code for the same send me....
1 Apr 2016 by Passion4Code
Hello,Please follow the below link. I hope that will help you some way.ASP.NET MVC 4 using Google Calendar API via OAuth 2[^]Thanks
4 Jul 2017 by Jaxam
My MVC5 application already has some users with assigned role created. I have a Ticket model with some basic ticket information. What I want to do now is I want to add an extra property called AssignedToUser to this Ticket model. In my Index View, I want to see a single User Name assigned to...
4 Jul 2017 by Ramesh Kumar Barik
Add one properties AssignedToUser of type int and one unmapped properties AssignedUserName (which will hold the name of that user) of string type in ticket model. So one ticket can assign to only one user at a time. When u fetch a ticket info that time you can set the AssignedToUser value. For...
8 Jan 2017 by UnStable Messi
hello guys !I'm using ELMAH to store exception logs to database. on elman.axd it's showing few columns like StatusCode User and more.how can I increase these columns ? add more columns to show on page ??and how can i change the existing columns ? like if it shows HOST column these...
6 Jan 2015 by jsagar05
Hi,I have created a model class using Database first approach in MVC5.I used the ADO.net for connection with Sql server.But now I added a new table in sql server.What I need to do to use this table.Can this new table be added in the same existing .edmx model.Please...
6 Jan 2015 by King Fisher
Refert this linkHow to update ADO.net Entity Data model[^]
24 Mar 2017 by Richard MacCutchan
Please do not post the same question in multiple forums. I have given you a full answer in the C# forum.
8 Aug 2016 by Kats2512
Hi,I am new to MVC and I am trying to add a user to a role after login. I have managed to use the AuthorizeRoles on actions in a controller but when trying to add a user to a like as per the below code I get an error saying User Not Found.System.Web.Security.Roles.AddUsersToRole(new...
8 Aug 2016 by njammy
HiI imagine thathttpContext.User.Identityis not being set to the logged in user.You need to make sure that in your application some code is setting it to correct value.An example is to use FormsAuthentication to set the cookie and configure FormsAuthentication in web.config for it to work.
2 Dec 2014 by Member 10922780
I've created a training site in MVC 5. I've been asked how easy it would be to add webinar capability to it. All my "webinar" searching shows webinars on MVC, but not how to add a webinar page to an MVC app.Any suggestions on where to start?
21 Sep 2015 by vini vasundharan
I want to add a '+' symbol below the table that shows the content of a particular table enabling the user to add another row of data to the table. I want the data to be saved in the database.I tried integrating my two current views together but it doesn't work. Here is my View for...
17 Sep 2015 by Krunal Rohit
1st apporach:The View you have shared here is showing all the records from database. If you want to add one more row which means that you are creating a new record. For that you'd be requiring a different View. (Which you removed already)2nd approach:You can do it via jQuery. See this:...
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.
9 May 2015 by Member 11677949
Execuse me, How we can add an image in Html code of asp.net mvc5..and how we can to change the colour of Navigation Bar in Layout..please answer for me..
18 Aug 2014 by ZainNabi
I have 2 roles Admin and DonorUpon registration any user must be added to the Donor role. How do I achieve this with identity and mvc5. [HttpPost] [AllowAnonymous] [ValidateAntiForgeryToken] public async Task Register(RegisterViewModel model) ...
18 Aug 2014 by Snesh Prajapati
First check for result, then only add role. That mean change the position of UserManager.AddToRole like:var user = model.GetUser();var result = await UserManager.CreateAsync(user, model.Password);if (result.Succeeded) result = UserManager.AddToRole(user.Id, "User");You can add...
29 Mar 2016 by granger007
I have made a simple MVC project and added a .svc file to it and trying to call the function under the .svc file from another client project but every time i am getting the error for Additional information: There was no endpoint listening at...
15 Apr 2016 by Amit-kumar-Amit-Kumar
Previous I was working on the Asp.Net(C#) with the ADO.Net Web Application, Now i want move on MVC 5. I am totally new in the MVC.I want to know which one is better in MVC 5, that ADO.Net or Entity Framework ?What I have tried:I have not perform any project with the use of MVC...
15 Apr 2016 by Richard Deeming
Which is better: a speedboat, or a Ferrari? *Without knowing the intricate details of your project, or your team's experience, capabilities and preferences, there's no way we can tell you which technology is "better". They're both pretty good, and both perfectly usable in ASP.NET MVC....
6 May 2023 by OriginalGriff
This is one of the most common problems we get asked, and it's also the one we are least equipped to answer, but you are most equipped to answer yourself. Let me just explain what the error means: You have tried to use a variable, property, or a...
6 May 2023 by ahmed_sa
I working on MVC razor pages asp.net core 7 . I can't display success message after submit and insert data on same page . I get error System.NullReferenceException: 'Object reference not set to an instance of an object.' error happen on...
13 Nov 2015 by Member 11849988
I have a controller named CustomersInfoAPIController. I'm using Knock out, webapi2, asp.net mvc5 to build an application. I'm binding the data using knout JS. When I run the application and debug the knockout script, I don't see any error .When I try to insert data using AJAX I see error...
13 Nov 2015 by Tadit Dash (ତଡିତ୍ କୁମାର ଦାଶ)
I don't see the method "CustomersInfo" in your controller codes. So, as it is absent, it is giving you a 500 error.
21 Oct 2016 by cigwork
Use dev tools (F12 in Chrome) to inspect the JavaScript that the client has. You might find the URL supplied for the call is not what you expect it to be.Does this...url: '@Url.Action("SetSelectedHO","../../Controllers/ReportsController")'... generate a valid URL? It looks as...
21 Oct 2016 by Vincent Maverick Durano
You don't need to specify the path when using Url.Action() method. You need to specify the Controller name instead.So if you have a Controller that was named ReportsController, then you could try doing something like this:url: '@(Url.Action("SetSelectedHO","Reports"))'Note that...
24 Oct 2016 by Anjali0904
Solved.It worked without giving an controller reference in urlurl: "SetSelectedHO",Thanks.
21 Jul 2019 by Anjali0904
For OnChange event of a dropdown, I am making a ajax call. In the url path, when I give the Controller/Action path it does not hit the method at all.My code looks like:function FillHO() { //alert('Test'); var stateId = $('#ddlHO').val(); $.ajax({ type: "POST", ...
18 Oct 2018 by Member 14024864
This worked for me: url:'../Controller/action'
31 Oct 2019 by Member 14641047
Thanks for solution 4 its work forme , on laravel on ubuntu
4 Apr 2017 by kkakadiya
Hello, in my Controller, json result returns start date as 04/04/2017 but when I print start date in AJAX call return in view it displays as /Date(1488133800000)/ I manipulated start date as below but it prints 4/4/2017.I need to print 04/04/2017. how can I do that? $.ajax({ url:...
4 Apr 2017 by Wessel Beulink
tr.append("" + SDate.ToString("dd-MM-yyyy"); + "");
4 Apr 2017 by Karthik_Mahalingam
try var str = '4/4/2017'; var parts = str.split('/'); var month = ('0' + parts[0]).slice(-2); var day = ('0' + parts[1]).slice(-2); var year = parts[2]; var result = month + '/' + day + '/' + year;
23 Feb 2021 by Krishna Veni
i have called ajax call that had worked successfully with success function also but i have used on modal popup in my project. once modal popup closed then i had called ajax cal at the time action method called that had excuted sucessfully with...
6 Apr 2019 by Abrar Kazi
View:@using (Ajax.BeginForm("AddBranchContact", new AjaxOptions { HttpMethod = "POST", UpdateTargetId = "section3", OnSuccess = "$('#myModal1').modal('hide');" })){}Model:public JsonResult AddBranchContact(BranchViewModel objBranchContact) { List...
6 Apr 2019 by Member 14216629
It seems to me, You are trying to mix Ajax.BeginForm and Html.BeginForm. Yout code should work without @Html.Beginform block. Try to use this code without this block.
2 Apr 2018 by ejaz mirza
List files = new List(); List fi = new List(); string dpath = Path.GetDirectoryName(Server.MapPath("~/Files/")); while (sd.Read()) { if (sd["attachmentname"] != DBNull.Value) ...
2 Apr 2018 by Christiaan van Bergen
In your view you define the Model@Model List Remove that line. The @Model is a dynamic, if you put a List into it from your controller, it will work as a List of strings. Also, because the items in the list are strings, you do not have use the .ToString() on each and every @Model[i]
5 May 2022 by Majid Farhan
Projcet in MVC & VB.net This is the full error message: System.Data.Entity.Core.ProviderIncompatibleException: 'An error occurred accessing the database. This usually means that the connection to the database failed. Check that the connection...
5 May 2022 by Sandeep Mewara
OP confirmed that he was using out-of-date mysql version and hence was facing it. [Posting to pop it out of unanswered queue]
24 Jan 2020 by Member 13522501
hi. i write below code in controller: public ActionResult Index() { var listOfPersonal = (from Personals in db.Personals select new Person { FirstName = Personals.FirstName, LastName = Personals.LastName, Phone = Personals.Phone }).ToList(); return View(listOfPersonal); } ...
24 Jan 2020 by F-ES Sitecore
Always google any error messages you get, there are lots of pages that explain the problem and solution, this is just one The entity or complex type 'Categories' cannot be constructed in a LINQ to Entities query.[^] You can search for more yourself The entity or complex type cannot be...
24 Jan 2020 by jimmson
As the message says, what you're doing is not supported in LINQ to SQL. Specifically, creating a new object Person. There is a simple workaround though. Just convert the data to .ToList() or .ToArray() and after that you can do Select: .ToArray().Select(i => new Person { ... });