Bundleconfig.Cs is even needed

Asked

Viewed 687 times

0

I’m reading something about MVC, Webapi and Angularjs. All the examples I got, whether from Macoratti or others ask to make some configuration in Bundleconfig.cs. However I use VS2017 and when creating the test project, in the folder App_Start I don’t have that file. I must create it and insert the lines inside it?

3 answers

1


Good night, my friend.

Bundleconfig.Cs is very important yes!

Gives you more possibilities.

Example:

Center and choose the order of running scripts . js and the same thing for your style files . css...

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 this file in the Angularjs project itself.

I hope I’ve helped.

  • When I created the project, I did it as MVC and didn’t create the file. What do I do then?

  • 1

    @Marconi, thanks. I managed to create the file.

1

Webapi does not use BundleConfig.cs "directly", just for the record due to the tag you added , Webapi is for creating services with REST, and can have the Json or Xml format in the body of the response and payload.

I won’t go into detail about Webapi, but back to BundleConfig.cs, it has meaning to be used on web pages, so you will not use with Webapi, at least "not directly", since it is possible in a same project to work Webapi and other type, such as MVC.

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

By tag I think you want to create a project with Asp.net-mvc, so in VS press Ctrl + Shift + N and select ASP.NET Web Application (I use version 4.6.1):

ASP.NET Web Application

Then select MVC (note that if you want to create a project MVC+Webp API select where this written Add folders and core References for: and select the option Web API):

mvc

After creating note that the folder appears App_Start

Pasta App_Start

  • I created an MVC project. Before I had created an MVC and WEBAPI, but I gave this up for now and created another MVC only. This is a test, where the guy wants an MVC project with Web API and Angular and Ado.Net and Entity.

  • I created the MVC project but Empty and not with the MVC template. I don’t know if it was that, but I already created Bundleconfig in my project, following the link of colleague Marconi.

  • @pnet but that is to create manually if the project is new and has nothing or this learning do as I said.

0

BundleConfig or bundling It is not just a question of organization, but of performance

Now in a webapi it makes no sense to use unless you have made some web pages or a documentation (more than one page) that needs css/js

Edition: MVC or not, when Voce has a Webs(View) page and makes use of content(js/css) it is recommended to use bundling(Bundleconfig) to optimize first-load and organize its content.

inserir a descrição da imagem aqui

Voce can read more on "Documentation"

  • I know web API doesn’t make sense, but the question is for MVC. I put the Web API tag due to the fact that I will use it as well, but not just a web API project, but along with MVC.

  • MVC or not, when Voce has a Webs(View) page and makes use of content(js/css) it is recommended to use bundling(Bundleconfig) to optimize first-load and organize its content

  • so MVC - V view, yes it is recommended you use bundling to improve first-load performance and organize your code

  • Thanks man, I already added Bundleconfig to my project. I don’t know why VS2017 didn’t create if I created a MVC project only. I will use REST in the project with Web API, it is a test requirement, I will use for queries. I will use Ado.Net to persist and Entity to get in the bank and bring the queries, since they want Ado.Net and Entity obligatorily.

  • a separate recommendation, read a little about layered architecture.

  • Thanks, that’s what I’ve been doing. It’s just that sometimes there are doubts and I run here.

Show 1 more comment

Browser other questions tagged

You are not signed in. Login or sign up in order to post.