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 Updated

MVC5 

17 Oct 2016 by #realJSOP
The only real way to add XML comments to your code is to do it manually. There is a helper extension available for Visual Studio, called GhostDoc. It helps ease the pain a little.Of course, you could write an application to do it for you, but it would take a lot less time manually commenting...
14 Nov 2016 by #realJSOP
I would think you would have to write a recursive method that wraps the call to ChangeFilterAttribute.
6 Dec 2016 by #realJSOP
Here's one method for getting a list of properties from your "text". The result is a list of strings that are your property names.I noticed that your text is somewhat malformed (missing some spaces), but this code seems to handle it okay.string text = "public class Person { public string...
17 Oct 2017 by #realJSOP
I'm trying to get a DropDownListFor to display with the bootstrap style, but everything I've tried has failed to render the control as desired. How do I make it happen? What I have tried: I've NuGet'd bootstrap-select, and did this in BundlesConfig.cs bundles.Add(new...
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...
29 May 2018 by #realJSOP
Oranges. Remember, the quality of the question dictates the quality of the answer. ============================= Before the down-voting nazis chime in with pointless 1-votes, keep in mind that I'm trying to make a point. The question provides NO CODE to evaluate, so we can't POSSIBLY help...
15 Oct 2018 by #realJSOP
Put your code into a try/catch block and evaluate any exception that might be thrown. My guess is that maybe the AppFiles\Images path does not exist, or that the filename is somehow invalid, or maybe that it already exists in the specified path. Some exception handling on your part will either...
15 Oct 2018 by #realJSOP
It's a play list file, not a video/audio file. Google will reveal what you need to do, but you can try Banshee Media Player, or maybe HLS-Player. Beyond that, it's not your job to make sure something will work on the client side besides letting the user know what he needs of have installed,...
11 Feb 2019 by #realJSOP
I am starting a MVC5 app, and I want to use the identity functionality without Entity framework. Here are the specifics: 0) MVC5 (.Net 4.6n) with individual user authentication (either via a standard userid/pwd login, or with a common access card (CAC). 1) No external logins, such as facebook,...
4 Apr 2019 by #realJSOP
(The way I'd do it) Instead of having two buttons, use a checkbox to indicate whether the user does or does not have the role, and have a single submit button.
17 Apr 2019 by #realJSOP
You need to learn about how to use ADO. Codeproject Article Search Results[^]
14 Jul 2019 by #realJSOP
If your DBA was smart (or even just a little self-aware), he will have turned off the ability to send emails from the database. You can ask him, but be prepared for a negative response. Sending emails from a web site is beyond trivial. When the user logs on, send the email to him if...
27 Nov 2019 by #realJSOP
0) Start a new MVC5 project, and make sure it includes user authentication. 1) Update all of the nuget packages in your new project. 1) That's all you have to do to include user authentication/authorization in a MVC app, unless you want to modify the views that the user is presented with to...
18 May 2020 by #realJSOP
Instead of doing it that way, redirect the user BEFORE they log in to the ASP.Net web site, and let the MVC site handle the login stuff.
7 Jun 2020 by #realJSOP
ViewData content is not persistent between page requests.
20 Nov 2014 by /\jmot
6 Sep 2017 by 1Future
Hi All, I'm having an issue with my Popup confirmation message box in my MVC project. basically i have the following: //document.FileName is the file name i'm returning from the database @Html.ActionLink("Delete", "DeleteDocument", "Document", new { id = document.Id, caseId = document.CaseId...
13 Dec 2017 by 1Future
I need to separate a list of returned names by comma in my MVC project View. I'm struggling to achieve and i have a feeling its an easy job. var names = dbcontext.EmployeeTable.Select(x => x.Name).ToList(); in my view i'm looping through this object like this: @foreach(e in names) { ...
1 Nov 2016 by 1suli0
I'm just started learning Bootstrap and ASP.Net MVC, a got little stuck.This is my view:@model Vrtic_2546.Models.Dogadjanja@{ ViewBag.Title = "Create"; Layout = "~/Views/Shared/_Layout.cshtml";}Create@using (Html.BeginForm()) { ...
4 Nov 2016 by 1suli0
@{ ViewBag.Title = "GalerijaIndex"; Layout = "~/Views/Shared/_GalerijaLayout.cshtml";}
5 Dec 2016 by 1suli0
I'm trying to build simple photo gallery, with BxSlider and I implemented adding and deleting functionality, but slider doesn't show images after page loads,only shows white box, and I have no idea what is the problem.This is the controller:using System;using...
9 Feb 2022 by 2011999
I tried the code below, but it shows in view label and textbox vertically. What I have tried: @Html.LabelFor(model => model.Name, htmlAttributes: new { @class = "control-label col-md-2" })
23 Nov 2022 by 2011999
Payroll is Main Menu. and New Pay and Payment records of Sub menus. Payroll New Pay Payment Records When i am Click Payroll. not show the submenu's How can i get the Payroll of the submenus. What I have tried: ...
4 May 2018 by 204.sharma
Hi, I have a 7 properties model. I am appending model controls dynamically in view. now i want to get all controls values in my controller and if any error comes at server side then want to pass same model object to view. The requirement is collecting child information of a person. In view...
22 Nov 2018 by 204.sharma
Hi, I have created a pagedlist in mvc view. But now when i do pagination my model object properties lost on 2nd page and after pages. I am creating a report page on filter basis. So what is the best process to achieve this ? What I have tried: Here is my Model class public partial class...
17 Dec 2021 by 4L4K1
My first problem: How to change kendo UI MVC datetimepicker (v2021) to show like persian datetimepicker?[^] My second problem: Kendo MVC DateTimePicker accept DateTime DateTime is Gregorian but I must send PersianDateTime to it because second...
17 Dec 2021 by 4L4K1
how to change Kendo UI MVC DateTimePicker (v2021) to show like Persian DateTimePicker? all internet links are belong to v2018 and when I do the same thing for v2021 that not working for example I did changes like this video this GitHub project...
13 Dec 2017 by ________________
As variant: public string AllNamesSeparatedByComma(List names) { StringBuilder allNames = new StringBuilder(); foreach(string e in names) { allNames.AppendFormat("{0},", e); } return allNames.ToString(); }
21 Apr 2014 by __PP__
In Data u add like thispublic class RepositoryMap: EntityTypeConfiguration { public RepositoryMap() { this.ToTable("TableNameInDB"); this.HasKey(u => u.Id); this.Property(u => u.Name); } }
21 Apr 2014 by __PP__
http://thedatafarm.com/data-access/quick-look-at-reverse-engineer-db-into-code-first-classes/[^]
18 Dec 2015 by _Asif_
Automatically deleted in SQL Server? Not Possible! PeriodThe problem is in your code (code, triggers, Job, transaction, etc) not in the sql server for this kind of issue
3 Jan 2018 by _awatts
try Hashids - generate short unique ids from integers[^]
5 Apr 2016 by _ProgProg_
Dears,I am developing a page to upload users signatures with rules that:*Image must be PNG.*Image size must be no more that 4 MB.Now, i want to make the uploaded photo transparent by code if the user didn't make it transparent.Is that is possible? if yes, How?Thanks in...
14 Apr 2016 by _ProgProg_
Dears,I want to do some weird job which is: adding attributes dynamically to my model class without adding these attributes directly on each property in the model class.the whole story is:I have an MVC project using Code first with domain driven design so i have the following:Core...
30 Dec 2020 by _ProgProg_
Dears, I am handling user reset password in my APP and i am using the following code: if the user clicks forget password, system generates token by the following code: var token = manager.GeneratePasswordResetToken(userId); Generated token sent to user email with a link to update his new...
2 Oct 2014 by aarif moh shaikh
if (FileUpload1.HasFile) { FileUpload1.SaveAs(Server.MapPath("YourFolderName/" + FileUpload1.FileName)); }Note: Here Give Your folder Name where you want to store image. Thanks AARIF SHAIKH
6 May 2017 by Abdul Hannan
Hi Friends Since i am new to asp.net mvc Getting this error I want to show Profile to user in View It shows this error "The name 'o' does not exist in the current context" What I have tried: View @model Test.Models.Customer @o.CST_Name @o.CST_Email ...
8 Mar 2016 by Abhijit Wagh
I want to implement facebook login in my E-commerce website,I have searched many websites but havn't got complete solution.So if anyone can help me....What I have tried:tried in my application taken reference of many websites but havn't got the complete solution
23 Feb 2017 by Abhilash.J.A
Hello everyone,how to set default value "select" zero in dropdownlist in MVC 5?What I have tried:I have tied: @Html.DropDownListFor(model => model.listNumEmployeeVM, new SelectList(Model.listNumEmployeeVM, "idNumEmployees", "NumEmployeeDesc"), "0", "Select", new { @id =...
23 Feb 2017 by Abhilash.J.A
Hi,I did tried this code inside Controller Get method. And now it is working!!!objcountrymodel.listNumEmployeeVM.Insert(0, new NumEmployeeVM() { idNumEmployees = 0, NumEmployeeDesc = "Select" });View,@Html.DropDownListFor(model => model.listNumEmployeeVM, new...
21 Jun 2017 by Abhilash.J.A
I am working on MVC 5 project, there is view and partial page. After using foreach loop happening unwanted empty Below screen shot please find the image.[^][^]Here is html view on browser, below screen shot please find the image.[^]What I have tried:I have tried,Here...
3 Mar 2017 by Abhilash.J.A
I am working on MVC 5, there I have view and partial view.@foreach (var item in Model) { ...
27 Apr 2014 by Abhinav S
Try going through the following links...
26 Aug 2014 by Abhinav S
Assuming you are using forms authentication, there is no major drawback in this method.Try using System.Web.HttpContext.Current.User.Identity.IsAuthenticated in that case.
13 Jan 2015 by Abhinav S
You can encrypt any type of file. Audio files too can be encrypted using standard algorithms available.Note that there is a difference between compression and encryption.So you might want to be clear on what you need.
21 Jan 2015 by Abhinav S
If you are building a small application then it can be used.It ties in well with ASP.Net Identity Framework as well.Larger applications, maintenance makes it difficult.
14 Feb 2015 by Abhinav S
You can do this by using JavaScript -http://www.aspsnippets.com/Articles/Create-dynamic-textbox-using-JavaScript-in-ASP.Net.aspx[^]This can also be done via code behind -Adding Controls to an ASP.NET form Dynamically[^]C#.Net - Dynamically create textbox in asp.net [^]
3 Apr 2015 by Abhinav S
Some links that could help you -ASP.NET MVC 4 Models and Data Access[^]Creating a Connection String and Working with SQL Server LocalDB[^]Beginner's Guide for Designing ASP.NET MVC Applications using SQL Server and Entity Framework[^]
3 Apr 2015 by Abhinav S
There is no easy way to downgrade if you have used features specific to that release.The only option you will have is to start by running the same site in an earlier release and then slowly testing every feature.
11 Apr 2015 by Abhinav S
If you are using identity framework, password reset is not difficult to build.Some examples -Create a secure ASP.NET MVC 5 web app with log in, email confirmation and password reset [^]Implementing custom password policy using ASP.NET Identity[^]There is no hard and fast rule that you...
28 Apr 2015 by Abhinav S
ASP.Net provides SignalR[^] which can be very useful when there is a need to implement notifications and real time updates. You can find a lot of tutorials on it as well.
28 Apr 2015 by Abhinav S
These might help -How to Create TreeView in MVC3[^]Simple TreeView implementation[^]
17 Jun 2015 by Abhinav S
Download Files in ASP.NET MVC 3 using Controller Action[^] should help you.
30 Jun 2015 by Abhinav S
Make sure that model object is not null. That is why you might be getting the error.
17 Aug 2015 by Abhinav S
Read more about single page applications here[^]. It does not however you cannot have layers like business logic and data access layer.
9 Nov 2015 by Abhinav S
Try these links -ASP.NET MVC Display an HTML Table with Checkboxes to Select Row Items[^]ASP.NET MVC - Multiple checkboxes for row selection in HTML table[^]ASP.NET MVC: Add a Select All Checkbox to a Checklist Table Using JQuery[^]
11 Nov 2015 by Abhinav S
More links and examples -Sending SMS with ASP.Net MVC[^]Sending SMS with MVC[^]In addition - Top 20 nuget packages for sms[^]
15 Nov 2015 by Abhinav S
You already have the code. Just uncomment it. //item += ' '; // item += ''
18 Nov 2015 by Abhinav S
Html 5 supports application cache. You could store this data in the cache[^].Alternately, you could store data in cookies.However, both these options come with security risks that need to be taken care of during implementation.
31 Jan 2016 by Abhinav S
Get the month and year from the recordset's column and convert them into a displayable month - year field.The code below is only a template. You will need to write something similar.foreach (var r in objbs){ cboMonth.Items.Add ( ...
31 Jan 2016 by Abhinav S
A user should have access to all pages in your application once they login.Thus, if you want to control access at controller (method) level and allow some users access to only some methods, then view the problem as an authorization one (not authentication).For more on authorization, try...
2 Mar 2016 by Abhinav S
You have not tried anything so start with Trim and cut video[^]. Try something and come back with questions.
20 Feb 2017 by Abhinaw Kumar Singh
I am new to MVC 5 authentication. Currently I tried Google Authorization using OwinThe code in startup.Auth.csvar googleOAuth2AuthenticationOptions = new GoogleOAuth2AuthenticationOptions{ ClientId = "Client-id", ClientSecret = "secret-key", CallbackPath = new...
27 Jun 2016 by Abhishek Burrnwal
@Resources.Registration.FirstName*@Html.TextBoxFor(model => model.FirstName) @Resources.Registration.LastName* @Html.TextBoxFor(model => model.LastName)
19 Sep 2017 by Abhishek Burrnwal
StudentMarks - ID, Subject, Marks, Grade Another Table GradeMarks - ID, Marks, Grade ID Marks Grade 1 91 A+ 2 81 A 3 71 B+ 4 61 B 5 51 C+ 6 41 C 7 31 D 8 21 F ID Subject Marks Grade 1 Hindi 57 2 Eng ...
6 Jun 2020 by Abhishek Duppati
Yes! you can send multiple details array. We can encapsulate the data like this: $.ajax({ type: "POST", url: "/Emp/MasterDetails", data: {'first_array':JSON.stringify(details1), 'second_array':JSON.stringify(details2), ...
11 Jun 2015 by AbhishekDotNet
Hello Friends,I am trying to learn Kendo UI control and Hence try to Implement a Kendo Grid.my Code is:Index.cshtml @(Html.Kendo().Grid() .Name("EmployeeKendoGrid") .Columns(c => { ...
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...
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...
20 Feb 2016 by Abrar Kazi
I want to pass 2 Datatables to my Stored Procedure as a parameter.Using db.Database.ExecuteSqlCommand .....Please help.What I have tried:I just have created 2 user type tables and stored procedure to insert record.I don't know how to pass Datatables as parameters.
17 Aug 2016 by Abrar Kazi
I want to apply lazy loading to my View where i am displaying a list of Products say Electronic devices. Initially i am displaying 10 products. On scroll bottom i want to load next 10 products using Lazy loading.A ready code snippet will be very helpful.What I have tried:I have...
18 Aug 2016 by Abrar Kazi
Interface : public interface Interface2 { void get2(); bool insert2(User U); }Implementation:public class HomeController : Controller { Interfaces _iInterfaces; Interface2 _iInterface2; public HomeController(Interfaces...
30 Aug 2016 by Abrar Kazi
I have created a string which is a xml format string generated using StringWriter and WriteToXml using the dataset .. now It works for less records in dataset but when records exceed 60k + which will be the real time scenario it throws a Memory Out of Exception while storing xml generated strj g...
8 Sep 2016 by Abrar Kazi
Model:public class Cedim { public float PEGID { get; set; } public float PIGID { get; set; } public float Type { get; set; } }View:@model PagedList.IPagedList@using PagedList.Mvc;
27 Sep 2016 by Abrar Kazi
Index :@using (Html.BeginForm(new { @style = "backgroundColor: '#f00', color: '#fff'} " })){ @{Html.RenderPartial("~/Views/Shared/_TermsAndConditions.cshtml");} }Partial View:
20 Oct 2016 by Abrar Kazi
Datatable : "columns": [ { "data": "SupplierId", "name": "SupplierId" }, { "data": "SupplierPIPCode", "name": "SupplierPIPCode" }, { "data": "SupplierName", "name": "SupplierName" }, { "render": function (data,...
24 Nov 2016 by Abrar Kazi
Initially td is filled by : @((objectModel.propertyModel ==true ? "Yes" : "")) Now on a button click Partial View is populated via ajax call on the same view but without any alteration to the above Table.Still as soon as ajax...
24 Nov 2016 by Abrar Kazi
I explicitly called the key up event. I don't know if its a valid solution or not but that worked for me.
17 Apr 2017 by Abrar Kazi
$('.DateOfBirth').datepicker({ changeMonth: true, changeYear: true, dateFormat: 'dd/mm/yy', defaultDate: new Date(), yearRange: "-100:+0" }); The above code brings a list of years ranging : 2017 to 1917 in the year...
17 Apr 2017 by Abrar Kazi
Update jquery. This is the only solution i found for this issue. Thanks to Karthik.
10 Oct 2017 by Abrar Kazi
I have the following Controller/HomeController Views/Home.cshtml and Home.aspx in same folder Now when this below code executes; public ActionResult Index() { return View(); } Controller fetches Home.aspx first not Home.cshtml. Any reason ? Why...
6 Aug 2014 by AdamASPGeek
You may check asphostportal.com. They also support ASP.NET MVC 5
8 Jan 2015 by AdamASPGeek
Hi ChakriKAC,Basically, you just need to upload all your files via FTP to your root folder. For more information, you can ask about Godaddy hosting support. You can read this tutorial too about how to upload MVC on shared hosting environment -...
2 Aug 2017 by adamwong_hk
You no need to change anything in your code but just use install-package Unity.WebApi instead. Hope it helps!
18 May 2014 by Ade.Ruyani.Z
Helloo... can somebody help me..this is my Code:Index.cshtml jQuery With Example @Scripts.Render("~/bundles/jquery") $(function () { $('.chkview').change(function () { ...
15 Nov 2018 by adhikar patil
Hello i am getting an below error when i am created the readymade create, edit etc views in mvc The name 'EntityState' does not exist in the current context Due to this my mapping is not working in mvc. Please give me the solution. This is working when i used System.Data.Entity...
20 Jan 2015 by Aditya Prakash Roy
Hii to all,i am working on project who having more than 300 tables in database,with using MVC 5 for UI and unity framework used.i also want to use entity framework,but i heard that EF having drawback regarding the loading or i will consume more time while Communicating with database...
13 Jul 2017 by aditya2314
Hello All, I am performing CRUD operation in MVC. I am stuck with checkbox. I am simple using html checkbox controls. For database connectivity i am using Entityframework technology. Reading ...
18 Jul 2017 by aditya2314
Hello Sir, I am making a registration page where i have follwoing columns. Student Registration Name : Email : Qualification : I am binding qualification dropdodwnlist in a partial view. But unable to call on StudentRegistration view. I am using two model. 1. Student ...
7 Feb 2018 by Adityakumar2318
This below code is working fine, i just wanted to do it using webclient without async. Or can we remove anyways asnc from below method and make it like regular method. // Calling method from program.cs using console application static void Main(string[] args) { ...
14 Dec 2016 by Admire Mhlaba
I want to know if there is a technique to use SignalR to get notifications when there is a CREATE, UPDATE And DELETE operation on any of my tables in the database. This way I can cache database data and issue a new cache request whenever SignalR sends a notification. The challenge is SignalR...
5 Jan 2017 by Admire Mhlaba
Good day, I need help to fix a logical error within an anonymous function executing inside await Task.Run(() =>. the logical error here is that nothing is being written to the file and no error is being raised inside try-catch block here is the code:public static async Task...
5 Jan 2017 by Admire Mhlaba
This is working but I need help to lock this method during execution to avoid race condition public static async Task LogActivityAsync(string source, string message) { try { string logFile = "~/App_Data/ActivityLog.txt"; ...
15 Dec 2017 by Adnan Okko
I am using the jQuery function toggle() with a button to toggle between a DropDownListFor and EditorFor. The function is as follows: function toggler() { $("#DDLF, #EF").toggle("slow"); } What I have tried: The code for the button, DropDownListFor and EditorFor is:
12 Aug 2016 by adriancs
class ModelItem{ public DateTime EventDate; public int ScheduledEventId; public ModelItem(DateTime date, int id) { EventDate = date; ScheduledEventId = id; }}public string GetEventStr(){ List Model = new List(); ...
6 Oct 2014 by Afazal MD 3104209
AngularJS integration with Web API explained with a product list and added new product with get and post method.
21 Jun 2015 by afiqdoherty
In my controller code, I need to return two objects to the Details view (details.cshtml)Below is the Controller code:FinishProductCompleteForm FinishProductCompleteFormDetails =...