Seven Color flower Basic Authority System (2)-MVC project construction and preliminary adjustment

Source: Internet
Author: User

Create a new ASP. NET MVC project, Solution name SEVEN,MVC project name S.framework.webclient. Such as:

Creating an MVC entry will let you choose the authentication method, choose None, we want a blank clean MVC project. Whether or not to check unit tests as you like.

Now remove the parts of the MVC project that we don't need to use, such as Bootstrap, jquery, jquery validation, etc., which can be removed through the NuGet tool. Such as:

(If you don't have nuget, please google)

Please remove Bootstrap, Microsoft jQuery unobtrusive Validation (when removed, you are prompted to remove both jquery Validation and jquery, select Yes, remove), MODERNIZR, Respond JS.

After removing, check the Packages.config file under the project root directory, and the referenced package should be consistent (the version does not need to be consistent):

Removing the extra packages also requires modifying some of the files that have been created in the project (those files are used for those removed packages).

Layout page, please modify it to this:

Here first not to consider the function of bundles, you can finally re-integration, here first without branching.

Site main style file (/CONTENT/SITE.CSS), remove the unrelated style, only set the body style, CSS as follows:

  1  body  {  2  font-size : 12px ;  3  font-family : " Trebuchet MS "Verdana, Arial, Helvetica, Sans-serif ;  4  margin : 0 ;  5  padding :  0 ;  6  width :  100% ;  7  height :  100% ;  8 } 
Site.css

Remember to refer to Site.css in the layout page.

HomeController only need to keep index this action, the corresponding view also only needs to preserve the index.cshtml, while emptying the contents of index.cshtml, write a "Hello world! ”。

Scripts under the _references.js please do not delete, used for JS smart hint.

Now, the structure of the project should look like this:

Run it and see "Hello world! ”。

App_start under the 3 configuration class, here a little introduction, do not expand, interested friends please turn over the information.

Bundleconfig, resource packaging configuration file.

The default contains references to JS and CSS such as Bootstrap, jquery, Jquery.validate, Modernizr, respond, and so on, which are automatically included when creating an MVC project.
These plugins have been removed, so delete them.

Filterconfig, filter configuration file.

You can get to know the 4 big filters of MVC, not to repeat them here.
By default, exception handling filters are added without tubes.

Routeconfig, routing configuration file

This is very powerful and complex, but the default setting basically meets our needs, so it doesn't have to be expanded.

These 3 configuration files are referenced in Global.asax.

Such an important configuration class, carry out more convenient maintenance, the structure is more clear.

Create a new class library, name S.framework.web, and create a folder config under its root directory.

Then move the 3 configuration classes under App_start under the MVC project to the past, and don't forget to adjust the configuration class namespace to S.framework.web.config.

The class library needs to refer to the 3 DLLs SYSTEM.WEB.MVC, System.Web.Optimization, system.web, and it is important to note that the references to these DLLs should be consistent with the version referenced in the MVC project. You can right-click those DLLs in the MVC project to view the properties to confirm the physical path of the referenced DLL.

SYSTEM.WEB.MVC, System.Web.Optimization are all in packages, so when you add these 2 references in S.framework.web, browse to the Packages folder under the solution root to find the appropriate DLL so that the version is consistent.

System.Web a direct search for an assembly is a good reference.

Now create a separate s.framework.web to try and compile the pass.

The 3 configuration class files under the MVC project can be deleted. Now let the MVC project refer to the S.framework.web project, and then adjust the code in the Global.asax to ensure that the new configuration class is used.

At this point the solution should be compile error-free.

As an obsessive-compulsive disorder, I mean the code in global should also be hidden in the s.framework.web.

Create a class under the S.framework.web root directory, name shttpapplication, copy the global code, such as:

Finally, let the MVC project's global inherit this shttpapplication class, such as:

At this point, the MVC project was built and the initial adjustment was completed. Its directory structure is this:

Run try, "Hello world! ”。

Seven Color flower Basic Authority System (2)-MVC project construction and preliminary adjustment

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.