ASP.Net MVC 4捆绑

编程入门 行业动态 更新时间:2024-10-16 02:24:31
本文介绍了ASP.Net MVC 4捆绑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

code大量的,我已经看到这个参考:

Lots of code that I have seen reference this:

@section Scripts { @Scripts.Render("~/bundles/jqueryval") }

这是伟大的,它的工作......如果东西是包括在内。我一定要添加一个引用得到这些?使用的NuGet?复制一个DLL?哪里这是从哪里来的?

Which is great, and it works...if "something" is included. Do I have to add a reference to get these? Use NuGet? Copy a DLL? Where does this come from?

当我跑我的项目,我得到一个404为该资源。

When I run my project, I get a 404 for that resource.

推荐答案

您需要创建包。这通常是在你的ASP.NET MVC 4项目 App_Start \\ BundleConfig.cs 文件来完成。它在捆绑和微小的所有解释。

You need to create the bundle. This is often done in the App_Start\BundleConfig.cs file in your ASP.NET MVC 4 project. It is all explained in Bundling and Minification .

在 BundleConfig 类,你需要像这样(此方法应该在的Application_Start 执行):

In the BundleConfig class you need something like this (this method should execute in Application_Start):

public static void RegisterBundles(BundleCollection bundles) { bundles.Add(new ScriptBundle("~/bundles/jquery").Include( "~/Scripts/jquery-{version}.js")); bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include( "~/Scripts/jquery.unobtrusive*", "~/Scripts/jquery.validate*")); // ... more registrations ... }

JavaScript源文件中的脚本文件夹是否存在应。以上链接的教程介绍了如何版本在缩小的发布版本等捆绑在一起。

The javascript source files should exists in the Scripts folder. The tutorial linked above explains how minified versions are bundled in the release build etc.

更多推荐

ASP.Net MVC 4捆绑

本文发布于:2023-10-11 10:16:01,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1481412.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:ASP   Net   MVC

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!