BundleConfig.cs is really necessary

0

I'm reading something about MVC, WebAPI and AngularJS. All the examples I have taken, either from Macoratti or others ask to do some configuration in the BundleConfig.cs. However I use VS2017 and when creating the test project, in the App_Start folder I do not have this file. Should I create it and insert the lines inside it?

    
asked by anonymous 06.12.2017 / 23:57

3 answers

1

Good evening, my friend.

BundleConfig.cs is very important indeed!

It gives you more possibilities.

Example:

Centralize and choose the order of execution of .js scripts and the same thing for your .css style files ...

I say this for ASP.NET MVC projects, in a project with WebAPI, this file will not make much sense, especially if it is with AngularJS, which can replace everything you would do in that file in the AngularJS project itself.

I hope I have helped.

    
07.12.2017 / 01:44
1

WebAPI does not use BundleConfig.cs "directly", just to appear because of the tag you added "> asp.net-web-api , WebAPI is for creating services with REST, being able to have the Json or Xml format in the response body and of the payload.

I'm not going to go into details about WebAPI, but coming back to BundleConfig.cs , it makes sense to be used in web pages, so you will not use with WebAPI, at least "not directly" since it's possible in one project work WebAPI and other type such as MVC.

Now speaking about creating the project and BundleConfig.cs is missing, it must have been because you created a Web site (shortcut Shift + Alt + N ) with Razor v3, it does not come with the folder App_Code or App_Start

By tag + N and then select N and select Ctrl ASP.NET Web Application (I use version 4.6.1):

  

ThenselectMVC(notethatifyouwanttocreateaprojectMVC+WebpAPIselectwhereitiswrittenAddfoldersandcorereferencesfor:andselecttheoptionWebAPI):

  

Aftercreating,notethatthefolderApp_Start

  

    
07.12.2017 / 03:28
0

BundleConfig or%% bundling is not just a question of organization, but performace

Now in a webapi it does not make sense to use unless you have made some web pages or a document (more than one page) that needs css / js

Edit: MVC or not, when you have a web page (View) and use content (js / css) it is recommended to use bundling (BundleConfig) to optimize first-load and organize your content.

youcanreadmorein "Documentation"

    
07.12.2017 / 07:32