添加WebAPI并注册后Global.asax.
我们发现我们的网络应用程序在此行中断:
Line 17: GlobalConfiguration.Configure(WebApiConfig.Register);
Run Code Online (Sandbox Code Playgroud)
错误信息:
Could not load file or assembly 'Newtonsoft.Json, Version=4.5.0.0, Culture=neutral,
PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies.
The system cannot find the file specified.
Run Code Online (Sandbox Code Playgroud)
经过一些检查,我发现我们正在使用Json.net 6此MVC 5.1应用程序.这是否意味着我们要降级到Json.net 4.5的WebAPI工作吗?
在我的.csproj文件中,只有一个条目:
<Reference Include="Newtonsoft.Json, Version=6.0.3.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Newtonsoft.Json.6.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>False</Private>
</Reference>
Run Code Online (Sandbox Code Playgroud)
当我查看我的内容Json.NET时Manage NuGet Packages,它也说我Json.NET的版本是6.0.3.
另外,bindingRedirect我的声明已经有了web.config.
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" …Run Code Online (Sandbox Code Playgroud) 这是代码:
var collection = [new Date(2014, 11, 25), new Date(2014, 11, 24)];
var d=new Date(2014, 11, 24);
var idx= collection.indexOf(d);
Run Code Online (Sandbox Code Playgroud)
我想变量idx应该有一个值,1因为它是数组中的第二个值collection.但事实证明是这样的-1.
这是为什么?Date我需要注意的JavaScript 类型有什么特别的东西吗?
这是一个片段:
(function() {
var collection = [new Date(2014, 11, 25), new Date(2014, 11, 24)];
var d = new Date(2014, 11, 24);
var idx1 = collection.indexOf(d);
var intArray = [1, 3, 4, 5];
var idx2 = intArray.indexOf(4);
$('#btnTry1').on('click', function() {
$('#result1').val(idx1);
});
$('#btnTry2').on('click', function() {
$('#result2').val(idx2);
});
})(); …Run Code Online (Sandbox Code Playgroud)试图在现有项目中更新服务引用,我收到一条错误消息,
无法更新指定的OData API,因为现在仅支持连接服务的OData API.
aka链接(http://aka.ms/odatavsclientguidance)导致http://odata.github.io/odata.net/#OData-Client-Code-Generation-Tool.
VS 2017没有任何指示.
下面的说明将我带到OData Connected Serve VS扩展.(https://marketplace.visualstudio.com/items?itemName=laylaliu.ODataConnectedService)

滚动到扩展程序描述页面的底部,我们将看到有关其VS 2017版本的所有问题.
所以问题是:OData扩展是唯一一个在VS 2017中更新OData服务的吗?我们有什么走路?
@{
ViewBag.Username = "Charlie Brown";
string title1 = string.Format("Welcome {0}", ViewBag.Username);
var title2 = string.Format("Welcome {0}", ViewBag.Username);
}
Run Code Online (Sandbox Code Playgroud)
在MVC视图中,我使用如下值:
@Html.ActionLink(title1, "Index")
@Html.ActionLink(title2, "Index")
Run Code Online (Sandbox Code Playgroud)
在这里,title1工作正常.但title2ActionLink因编译错误而失败:
CS1973:'System.Web.Mvc.HtmlHelper'没有名为'StandardHeader'的适用方法,但似乎有一个名称的扩展方法.无法动态分派扩展方法.考虑转换动态参数或调用扩展方法而不使用扩展方法语法.
string.Format()有很多重载,但返回类型总是字符串.为什么变量声明使用var失败?
我在页面上的表单有点太大了.它收集月度测量数据.请看一下样本:
{
"Year":2013,
"Month":3,
"Records":[
{"Id":0,"Date":"3/1/2013","RiverSection":5,"UserNumber":56},
{"Id":0,"Date":"3/1/2013","RiverSection":7,"UserNumber":200},
{"Id":0,"Date":"3/1/2013","RiverSection":8,"UserNumber":556},
{"Id":0,"Date":"3/2/2013","RiverSection":5,"UserNumber":56},
{"Id":0,"Date":"3/2/2013","RiverSection":7,"UserNumber":200},
...
...
{"Id":0,"Date":"3/31/2013","RiverSection":7,"UserNumber":200}
}
Run Code Online (Sandbox Code Playgroud)
所以我将大数据发布到APIController.
我在使用Visual Studio调试器服务器的本地计算机上工作正常.但是我将代码上传到服务器(IIS 6)之后.它给了一个500 Internal Server Error.
我尝试发布一些示例数据并检查字符串化json的长度.
在一个样本数据集中,我的json的长度是5743,我得到了"成功".但如果json大小达到17345,我得到了一个500 Internal Server Error.
所以我试图增加json的限制.基于这篇文章
在Web.Config:
<system.web.extensions>
<scripting>
<webServices>
<jsonSerialization maxJsonLength="5000000">
</jsonSerialization>
</webServices>
</scripting>
</system.web.extensions>
Run Code Online (Sandbox Code Playgroud)
但它没有用.
还有另一个答案,使用:
var serializer = new JavaScriptSerializer();
serializer.MaxJsonLength = Int32.MaxValue;
Run Code Online (Sandbox Code Playgroud)
但是我们应该在哪里放置这些代码?在Global.asax?
请注意我使用的是IIS 6.所以这是一个问题吗?如何正确增加json大小的限制,以便我的数据可以达到WebApi操作?
谢谢你的帮助.
如果是模型优先,我们使用[MetadataType(typeof(ConceptMetadataSource))]附加MetadataSource文件,其中包含所有数据注释,如 [HiddenInput(DisplayValue = false)]或[Display(Name = "Title")].
例如:
[MetadataType(typeof(ConceptMetadataSource))]
public partial class Concept
...
Run Code Online (Sandbox Code Playgroud)
现在,我使用数据库优先方法,因为有一个现有的数据库.这次,实体类由edmx模型自动创建.在每个实体类的开头,下面都有注释行:
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated from a template.
//
// Manual changes to this file may cause unexpected behavior in your application.
// Manual changes to this file will be overwritten if the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
Run Code Online (Sandbox Code Playgroud)
由于一旦我们修改了数据库中的表,代码就会重新生成,每次重新生成实体类时都会删除数据注释.
谁能告诉我注释那些实体类的最佳方法是什么?谢谢.
entity-framework entity-framework-4 asp.net-mvc-3 database-first
我需要改变一切:
<label for="*">
Run Code Online (Sandbox Code Playgroud)
成
<label for="*" class="inline checkbox">
Run Code Online (Sandbox Code Playgroud)
但事实证明我所有人<label for="XXXXXX">都变成了<label for="*" class="inline checkbox">.是的,*字面意思是字符串而不是通配符.
为什么通配符只在Find中取代?我应该在Replace字符串中输入什么?
将ui-mask在'角UI utils的项目(链接)是有点太有限了.
例如,美国电话号码的第一个数字应为2-9.在ngPattern,它应该是
ng-pattern="/^\([2-9]\d{2}\)\d{3}-\d{4}(x\d{1,4})?$/"
Run Code Online (Sandbox Code Playgroud)
那么如何编写输入掩码以防止用户在第一个数字中输入0或1?我们应该为Angular使用更好的输入掩码吗?
在ui-grid中实现了更好的分页.该演示看起来不错.但它使用的是不稳定版本.
当我检查凉亭包裹时
bower info angular-ui-grid
Run Code Online (Sandbox Code Playgroud)
最新发现的是#3.0.0-RC.18.
安装凉亭后:
bower install angular-ui-grid#3.0.0-RC.18
Run Code Online (Sandbox Code Playgroud)
我发现不unstable.js使用.并且ui-grid.js安装时不包含任何功能enablePaginationControls.显然,没有安装那个不稳定的版本.
那么,获取不稳定文件的正确方法是什么?
刚查看了GitHub页面链接,发现有新的更新.
我们不希望仅仅通过bower安装单个文件,这违背了包管理的目的.
bower安装版本3.0.0-RC.18-7774d30怎么可能?
我试过了:
bower install angular-ui-grid#3.0.0-RC.18-7774d30 --save
Run Code Online (Sandbox Code Playgroud)
这是错误:
bower not-cached git://github.com/angular-ui/bower-ui-grid.git#3.0.0-RC.18-7774d30
bower resolve git://github.com/angular-ui/bower-ui-grid.git#3.0.0-RC.18-7774d30
bower ENORESTARGET No tag found that was able to satisfy 3.0.0-RC.18-7774d30
Additional error details:
Available versions: 3.0.0-rc.16, 3.0.0-rc.15, 3.0.0-rc.14, 3.0.0-rc.13, 3.0.0-rc.12, 3.0.0-rc.11, 3.0.0-rc.10, 3.0.0-rc.8, 3.0.0-rc.7, 3.0.0-RC.18
Run Code Online (Sandbox Code Playgroud) 关于{{for}}循环的问题jsRender.
演示显示我们可以遍历一系列复杂对象并显示它们的属性:
{{for languages}}
<div>
<em>{{>name}}</em>
</div>
{{/for}}
Run Code Online (Sandbox Code Playgroud)
但如果我languages只是一个List<string>怎么办?将{{>name}}无法显示.我们如何引用单个字符串值?
谢谢.
angularjs ×2
c# ×2
json.net ×2
.net ×1
angular-ui ×1
asp.net-mvc ×1
javascript ×1
jquery ×1
json ×1
jsrender ×1
regex ×1
wcf ×1