Get the App
SLTechnology News&Howtos  ›  Development  › 

How to make a website with MVC4

Shulou Source: shulou.com Published: 2022-06-03 12:57:11 10月02日 Update

How to use MVC4 to make a website, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain for you in detail, people with this need can come to learn, I hope you can gain something.

I heard that Win8 and v2012 were released, and today I reinstalled the system on a whim.

It feels like a good interface.

Install vs2012 to learn mvc4, unexpectedly did not find the Vs2012 professional version of the crack, simply download Express for Web, can be considered to support the genuine bar!

509m will soon be downloaded and then installed.

After installing the interface, it still feels a lot different from vs2010.

A brother said that the best way to learn is to complete a small thing independently. We are going to learn to make a small website. If you think of a good name, let's call it NineskyCMS. Anyway, the name CMS is badly used. I also follow suit. I hope I can finish her.

The official beginning of learning:

Open VS Express for Web-> New Project

Next step

OK, wait a moment to create the project to complete.

Take a look at solution Explorer, which is still very different from the folder generated by mvc3.

Run it and see how it works.

The interface is nice.

The folder structure doesn't like to be modified:

Delete InitializeSimpleMembershipAttribute under Filters

Delete the Images folder

Delete AccountController.cs under Controllers

Delete WebApiConfig.cs under App_Start

Open the RouteConfig.cs file

Routes.MapRoute (name: "Default", url: "{controller} / {action} / {id}", defaults: new {controller = "Home", action = "Index", id = UrlParameter.Optional})

Change action = "Index" to action = "Default". Ha ha, personal habits, I prefer Default

1. Open HomeController and change public ActionResult Index () to public ActionResult Default (), and delete public ActionResult About () and public ActionResult Contact ().

Change the Content folder to Skins. The revised style is as follows:

Modify the BundleConfig.cs and modify it as follows:

Namespace CMS {public class BundleConfig {/ / for more information about Bundling, visit http://go.microsoft.com/fwlink/?LinkId=254725public static void RegisterBundles (BundleCollection bundles) {bundles.Add ("~ / bundles/jquery"). Include ("~ / Scripts/jquery- {version} .js"); bundles.Add (new ScriptBundle ("~ / bundles/jqueryui"). Include ("~ / Scripts/jquery-ui- {version} .js") Bundles.Add (new ScriptBundle ("~ / bundles/jqueryval"). Include ("~ / Scripts/jquery.unobtrusive*", "~ / Scripts/jquery.validate*"); / / use the development version of Modernizr for development and information. Then, when you are ready for production, use the build tool on http://modernizr.com to select only the required tests. Bundles.Add (new ScriptBundle ("~ / bundles/modernizr"). Include ("~ / Scripts/modernizr-*"); bundles.Add (new StyleBundle ("~ / Skins/css"). Include ("~ / Skins/Default/Style.css")) Bundles.Add (new StyleBundle ("~ / Skins/jquery-ui/css"). Include ("~ / Skins/jquery-ui/jquery.ui.core.css", "~ / Skins/jquery-ui/jquery.ui.resizable.css", "~ / Skins/jquery-ui/jquery.ui.selectable.css", "~ / Skins/jquery-ui/jquery.ui.accordion.css", "~ / Skins/jquery-ui/jquery.ui.autocomplete.css", "~ / Skins/jquery-ui/jquery.ui.button.css" "~ / Skins/jquery-ui/jquery.ui.dialog.css", "~ / Skins/jquery-ui/jquery.ui.slider.css", "~ / Skins/jquery-ui/jquery.ui.tabs.css", "~ / Skins/jquery-ui/jquery.ui.datepicker.css", "~ / Skins/jquery-ui/jquery.ui.progressbar.css", "~ / Skins/jquery-ui/jquery.ui.theme.css") }}

1. Delete Vies/Account, delete Vies//Home/About.cshtml, rename Index.cshtml to Default.cshtml, delete Shared/ _ LoginPartial.cshtml.cshtml, delete Views/_ViewStart.cshtml

2. Open web.config and modify the database connection to

OK! When the work is done, the world is finally quiet!

The final interface is as follows:

Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

Tags: Files folders interface learning or website different good information name feeling project preparation help development support build create website very large clear Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker NVidia Linux vpn Apple