我正在使用Visual Studio 2012和MVC 4,在我的_Layout.cshtml中,我有以下内容:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/jqueryui")
@Scripts.Render("~/bundles/jqgrid")
@RenderSection("head", required: false)
</head>
<body>
@RenderBody()
@RenderSection("scripts", required: false)
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
在BundleConfig.cs中我有
public class BundleConfig
{
public static void RegisterBundles(BundleCollection bundles)
{
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/Scripts/jquery-{version}.js"));
bundles.Add(new ScriptBundle("~/bundles/jqueryui").Include(
"~/Scripts/jquery-ui-{version}.js"));
bundles.Add(new ScriptBundle("~/bundles/jqgrid").Include(
"~/Scripts/jquery.jqGrid.min.js"));
}
}
Run Code Online (Sandbox Code Playgroud)
我已经三重检查,我的脚本文件夹确实包含jquery.jqGrid.min.js,但它没有包括在内.
我的Html头看起来像:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<link href="/Viper/Content/css" rel="stylesheet"/>
<script src="/Viper/Scripts/jquery-1.8.1.js"></script>
<script src="/Viper/Scripts/jquery-ui-1.8.23.js"></script>
</head>
Run Code Online (Sandbox Code Playgroud)
任何想法为什么没有添加?
有没有办法从代码隐藏中读取System.Web.Optimization内容?我试着在dll周围戳,但我找不到一种方法来读取包内容(据我所知,它意味着通过处理程序来处理对bundle的调用.
我的意图是使用sass,由于转换(在缩小之上)会导致更重的处理,并将其生成为文件,然后将其提供给最终用户.通过使用WebRequest读取文件并保存响应,我找到了一个解决方案,但它只是觉得对我很讨厌.
.net c# asp.net asp.net-optimization system.web.optimization
由于每个版本的Asp.Net Identity之间有很多变化,有没有办法尽早获得任何即将发生的变化?
两者之间有什么区别:
https://www.nuget.org/packages/Microsoft.AspNet.Web.Optimization/1.1.0
和
https://www.nuget.org/packages/Microsoft.AspNet.Web.Optimization.WebForms/1.0.30506
有人请解释,非常困惑。:(
撞!
asp.net optimization asp.net-4.5 bundling-and-minification asp.net-optimization
我将现有的DBContext与MVC 5中的新IdentityDbContext结合起来.我设法将两个上下文组合在一起,但是当我运行我的应用程序并且正在创建模型时,我收到了以下错误消息:
Context.IdentityUserLogin :: EntityType'IdentityUserLogin'没有定义键.定义此EntityType的键.Context.IdentityUserRole :: EntityType'IdentityUserRole'没有定义键.定义此EntityType的键.
我有一个ASP.NET Web表单应用程序,使用Microsoft.AspNet.Web.Optimization包中的新Bundling和Minification功能在.NET 4.5上运行.
到目前为止,这是一个非常简单的设置,只需一个捆绑.
BundleConfig.cs
public static void RegisterBundles(BundleCollection bundles)
{
bundles.Add(new ScriptBundle("~/bundles/send").Include(
"~/scripts/GrowingInput.js",
"~/scripts/textboxlist/TextboxList.js",
"~/scripts/textboxlist/TextboxList.Livesearch.js",
"~/scripts/combobox/ui.combobox.js",
"~/scripts/jquery-ui-timepicker.js",
"~/scripts/msp.send.js"));
}
Run Code Online (Sandbox Code Playgroud)
Global.asax中
protected void Application_Start(object sender, EventArgs e)
{
BundleConfig.RegisterBundles(BundleTable.Bundles);
}
Run Code Online (Sandbox Code Playgroud)
Send.aspx
<%: Scripts.Render("/bundles/send") %>
Run Code Online (Sandbox Code Playgroud)
这始终在Web浏览器中呈现为<script src="/bundles/send"></script>忽略在web.config中将debug设置为true还是false.
我已经尝试添加BundleTable.EnableOptimizations = false;到BundleConfig.cs以强制捆绑,但这没有任何区别.
希望得到以下工作,就像在MVC网站中一样(Microsoft文档似乎建议Web表单应该是相同的).
我正在用EF写一个MVC5应用程序.我在第一次注册用户时在我的数据库中创建ASPNETUser表的项目中添加了ASP.NET Identity.但是现在,当我尝试自定义UserProfile时(如本文所列:http://www.asp.net/mvc/tutorials/mvc-5/create-an-aspnet-mvc-5-app-with-facebook- and-google-oauth2-and-openid-sign-on)
我得到以下内容:
The model backing the 'ApplicationDbContext' context has changed since the database was created. Consider using Code First Migrations to update the database
Run Code Online (Sandbox Code Playgroud)
是因为我已经指定了.edmx文件(MVC5Entities)=>(参见web.config中的2个连接字符串)?
这是我的web.config:
<connectionStrings>
<add name="DefaultConnection" connectionString="Data Source=DILS-S1301;Initial Catalog=MVC5;Integrated Security=True" providerName="System.Data.SqlClient" />
<add name="MVC5Entities" connectionString="metadata=res://*/Models.Mvc5Model.csdl|res://*/Models.Mvc5Model.ssdl|res://*/Models.Mvc5Model.msl;provider=System.Data.SqlClient;provider connection string="data source=DILS-S1301;initial catalog=MVC5;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
Run Code Online (Sandbox Code Playgroud)
我该怎么办?