项目:在.net 4.0框架下运行的ASP MVC 4:
在VS 2010 Express下运行应用程序(或在本地计算机上的IIS 7.5下部署并运行)时,操作的以下(伪代码)结果按预期工作
[HttpPost]
public ActionResult PostWord(Model model)
{
....
Response.StatusCode = 400;
Return new JsonResult { data = new {fieldName = "Word", error = "Not really a word!" } };
Run Code Online (Sandbox Code Playgroud)
(我已经分配了JsonResult对象的ContentType和ContentEncoding属性,但行为没有区别)
当deployable移动到Web主机(使用IIS 7)时,firebug告诉我响应是按预期的(400)但响应中没有JSON(即没有任何类型的文本).如果我删除该行
Response.StatusCode = 400;
Run Code Online (Sandbox Code Playgroud)
从动作中,JSON完美地形成在响应中,但当然响应状态代码是200(OK),这会干扰消费的javascript和适当的函数调用.
关于可能发生的事情以及如何解决这个问题的任何想法?谢谢
不久前我将一个项目从MVC 3转移到了MVC 4.
当我建立时,我得到了消息
1> No way to resolve conflict between "System.Web.Mvc, Version=3.0.0.0 ..." and , Version=2.0.0.0
1> Consider app.config remapping of assembly "System.Web.WebPages ..." from Version "1.0.0.0" to Version "2.0.0.0" to solve conflict and get rid of warning.
1> Consider app.config remapping of assembly "System.Web.WebPages.Razorfrom Version "1.0.0.0" [c:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\Assemblies\System.Web.WebPages.Razor.dll] to Version "2.0.0.0" [C:\Users\OEM\documents\visual studio 2012\Projects\DabTrial\packages\Microsoft.AspNet.WebPages.2.0.30506.0\lib\net40\System.Web.WebPages.Razor.dll] to solve conflict and get rid of warning.
Run Code Online (Sandbox Code Playgroud)
等等.
当我查看引用时,它们都是更高版本,而web.config仅引用更高版本.当我通过公钥令牌(在Windows资源管理器中)搜索整个解决方案目录时,我找不到引用早期版本的XML类型文件.
显然,文件的路径是不同的,但我找不到编译器被定向到早期.dll文件的路径的位置.
该项目构建并运行良好,但我认为编译器建议这些更改是有原因的.谢谢你的帮助.
我正在使用Hangfire和Postal从页面周期异步发送电子邮件(在 MVC 5 应用程序中)。创建电子邮件的线程使用RazorEngine项目。
Visual Studio 2013 (express) 项目设置为“发布期间预编译”,“允许预编译站点可更新”设置为 false。这具有显着的优势,因为我使用的是共享 Web 主机,并且无法更改应用程序池回收时间(20 分钟)。如果 20 分钟内未访问该站点,则该站点对请求的响应速度会明显加快。
但是,发布的网站具有用于电子邮件模板的“自动生成标记”.cshtml 文件(即使复制到输出目录设置为始终复制),并且(非 MVC)线程只有在我复制每次发布后,手动将 Visual Studio 项目中的 Views/Email 文件夹放入发布文件夹中。
有没有办法从“预编译”选项中排除某些 .cshtm 文件或整个文件夹,以便 .cshtml 文件可以在 MVC 之外使用。谢谢。
我正在按照Microsoft文档中的演练来介绍在vs代码项目中使用Typescript。当我尝试运行构建任务时,终端会显示
执行任务:c:\ whatever \ my带有空格的路径\ Projects \ ProjectName \ node_modules.bin \ tsc.cmd -p“ c:\ whatever \ my带有空格的路径\ Projects \ ProjectName \ tsconfig.json”
和错误
'c:\ whatever \ my'不被识别为内部或外部命令,
也就是说,文件夹名称中的空格使任务运行程序感到困惑。我需要类似的东西
call "c:\whatever\my path with spaces\Projects\ProjectName\node_modules\.bin\tsc.cmd" -p "c:\whatever\my path with spaces\Projects\ProjectName\tsconfig.json"
Run Code Online (Sandbox Code Playgroud)
如何设置VS Code,以便终端接收到可以解释的输入,其中目录名称中可以包含空格?谢谢
当前的task.json:
"version": "2.0.0",
"tasks": [
{
"type": "typescript",
"tsconfig": "tsconfig.json",
"problemMatcher": [
"$tsc"
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
Run Code Online (Sandbox Code Playgroud) 感谢您帮助我理解其中的一些内容:
假设我在MVC应用程序中有2个控制器 - 1个控制与销售人员相关的viewModels 1控制与销售相关的viewModels
每个都有自己的存储库,使用Entity框架访问数据(代码优先)
这两个存储库都设置为处理依赖注入,但也有0个参数构造函数,默认值使用相应的EF dataAccess.
salespeople控制器使用_salesPeopleRepository.getAllSalesPeople()函数,该函数返回一个销售人员列表以填充索引视图.
销售控制器需要访问相同的列表来填充下拉列表.
有几种方法可以将信息提供给销售控制人员,我想知道哪些选项被认为是最佳实践:
a)在控制器中
db = new DataContext();
_saleRepos = new SalesRepository(db);
_salesPeople = new SalesPeopleRepository(db);
.....
modelA.SalePeopleSelectList = SelectList(_salesPeople.getAllSalesPeople(),"id","name")
Run Code Online (Sandbox Code Playgroud)
b)在SalesRepository中 - 使用EF本身:
public IEnumerable<salesPerson> getAllSalesPeople()
{
return _db.SalesPeople.ToList();
}
Run Code Online (Sandbox Code Playgroud)
c)或在调用函数之前实例化和注入相同的数据访问对象
public IEnumerable<salesPerson> getAllSalesPeople()
{
return (new SalesPersonRepository(_db)).getAllSalesPeople();
}
Run Code Online (Sandbox Code Playgroud)
编辑
如果答案是),应该如何自定义提供商家的逻辑是1个库调用 - 例如说销售有STOREID和仓库检查该STOREID进入了销售的营业员STOREID匹配.是否应该通过salesPerson存储库或直接从dataContext对象访问用于商业逻辑目的的salesPerson对象(在salesRepository中)?
感谢您的想法和经验
感谢您的想法,以帮助相对的初学者了解WPF。
我试图在WAML应用程序的XAML文件中使用以下样式模板:
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary>
<Style TargetType="{x:Type RowDefinition}" x:Key="hideIfNotDischarged">
<Style.Triggers>
<DataTrigger Binding="{Binding DischargedBy28Days, Mode=OneWay}" Value="false">
<Setter Property="Height" Value="0" />
</DataTrigger>
</Style.Triggers>
</Style>
<Style TargetType="{x:Type RowDefinition}" x:Key="hideIfOutcomeKnownAndAlive">
<Style.Triggers>
<DataTrigger Binding="{Binding IsKnownDead, Mode=OneWay}" Value="false">
<Setter Property="Height" Value="0" />
</DataTrigger>
</Style.Triggers>
</Style>
</ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>
Run Code Online (Sandbox Code Playgroud)
稍后将在像这样的网格中使用:
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="30" />
<RowDefinition Style="{StaticResource hideIfNotDischarged}" />
...
Run Code Online (Sandbox Code Playgroud)
但是,如果有多个针对Type RowDefinition的样式元素,并且ResourceDictionary嵌套在MergedDictionary中(即使仅合并了一个子ResourceDictionary),则应用程序将失败
System.Windows.ResourceDictionary.DeferrableContent:项目已添加
也就是说,尽管这两种样式具有不同的键,但是资源字典试图添加名称完全基于目标类型的字典项(并忽略键)。
我将如何克服这些问题方面的任何帮助将不胜感激。
ryan niemeyer在这个博客上的代码bost声明了一个空函数(命名结果),然后为函数添加属性:
ko.dirtyFlag = function(root, isInitiallyDirty) {
var result = function() {},
_initialState = ko.observable(ko.toJSON(root)),
_isInitiallyDirty = ko.observable(isInitiallyDirty);
result.isDirty = ko.computed(function() {
return _isInitiallyDirty() || _initialState() !== ko.toJSON(root);
});
result.reset = function() {
_initialState(ko.toJSON(root));
_isInitiallyDirty(false);
};
return result;
};
Run Code Online (Sandbox Code Playgroud)
在返回对象之前,这有什么优势可以简单地创建一个对象并分配相同的属性?
回应评论请求我看起来如何:要么宣布
var result={};
Run Code Online (Sandbox Code Playgroud)
在声明中,或作为一种风格的东西:
ko.dirtyFlag = function(root, isInitiallyDirty) {
var _initialState = ko.observable(ko.toJSON(root)),
_isInitiallyDirty = ko.observable(isInitiallyDirty);
return {
isDirty : ko.computed(function() {
return _isInitiallyDirty() || _initialState() !== ko.toJSON(root);
}),
reset : function() {
_initialState(ko.toJSON(root)); …
Run Code Online (Sandbox Code Playgroud) 我使用MDN文档中为Set对象描述的构造函数编写了一些代码。不幸的是,Internet Explorer 11忽略了构造函数中的任何可迭代参数。我快速尝试覆盖构造函数(下面的代码),但是没有运气(Set.prototype.size返回-'this'不是set对象)。
var testSet = new Set([0]);
if (testSet.size === 0) {
//constructor doesnt take an iterable as an argument - thanks IE
var oldProto = Set.prototype
Set = function (iterable) {
if (iterable) {
iterable.forEach(this.add.bind(this));
}
};
Set.prototype = oldProto;
}
Run Code Online (Sandbox Code Playgroud)
有没有一种方法可以让Set构造函数传递一个可迭代的参数,并且仍然可以在IE中工作?我猜下一个最佳选择是创建某种工厂方法(Set.create),该方法将返回一个新的Set实例。
如果我在 indexedDB/Dexie 表中有以下记录:
{
id: 1,
name: "foo",
children: [{id: 12, bar: "b"},
{id: 14, bar: "c"}]
}
Run Code Online (Sandbox Code Playgroud)
每个孩子的 id 都是唯一的。也就是说,只有 1 条记录包含给定 id 为 14 的子记录。
anyOf([3, 7, 9])
javascript ×2
.net ×1
architecture ×1
asp.net-mvc ×1
c# ×1
dexie ×1
ecmascript-6 ×1
indexeddb ×1
json ×1
wpf ×1