The localhost page isn’t working. localhost redirected you too many times

I got a problem when debugging my MVC program and I want to acces to my db called “UserActivity”. on the browser, it saying that “The localhost page isn’t working localhost redirected you too many times.” but without showing the specific error location. here is my UserActivtyController, GET /UserActivity/Index code: Really appreciate if there anyone … Read more

There is no ViewData item of type ‘IEnumerable‘ that has the key country

In your action change ViewBag.countrydrop = item8 to ViewBag.country = item8;and in View write like this: Actually when you write @Html.DropDownList(“country”, (IEnumerable)ViewBag.country, “Select country”) or Html.DropDownList(“country”,”Select Country) it looks in for IEnumerable<SelectListItem> in ViewBag with key country, you can also use this overload in this case: See Working DEMO Example

Styles.Render in MVC4

It’s calling the files included in that particular bundle which is declared inside the BundleConfig class in the App_Start folder. In that particular case The call to @Styles.Render(“~/Content/css”) is calling “~/Content/site.css”.

How to use html.ValidationMessageFor

It was silly simple…..I just didn’t add the ErrorMessage field as part of the [Required] decorator. For example: Now, if a user either doesn’t enter anything in the name fields, or enters something over 30 characters, the Post method doesn’t get executed and the user gets a little message telling them what’s wrong.

How to add reference to System.Web.Optimization for MVC-3-converted-to-4 app

UpdateVersion 1.1.x is available, read the release notes: https://www.nuget.org/packages/Microsoft.AspNet.Web.Optimization The Microsoft.Web.Optimization package is now obsolete. With ASP.NET (MVC) 4 and higher you should install the Microsoft ASP.NET Web Optimization Framework: Install the package from nuget:Install-Package Microsoft.AspNet.Web.Optimization Create and configure bundle(s) in App_Start\BundleConfig.cs:public class BundleConfig { public static void RegisterBundles(BundleCollection bundles) { bundles.Add(new ScriptBundle(“~/Scripts/jquery”).Include( “~/Scripts/Lib/jquery/jquery-{version}.js”, “~/Scripts/Lib/jquery/jquery.*”, “~/Scripts/Lib/jquery/jquery-ui-{version}.js”) ); … Read more