小编Sac*_*nth的帖子

配置错误:System.Web.Helpers

我将一个站点部署到服务器,我收到此错误.为什么我这样做?

Configuration Error 
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately. 

Parser Error Message: Could not load file or assembly 'System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

Source Error: 


Line 16:       <assemblies>
Line 17:         <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
Line 18:         <add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
Line 19: …
Run Code Online (Sandbox Code Playgroud)

iis-6 web-config .net-4.0 asp.net-mvc-3

12
推荐指数
1
解决办法
2万
查看次数

EF迁移:ALTER TABLE语句与FOREIGN KEY约束冲突

我有这些课程

public class Bid : ...
{
   ...

   [Required]
   public virtual TraderUser Trader { get; set; }
}

public class TraderUser : ...
{
   ...
}
Run Code Online (Sandbox Code Playgroud)

然后我按以下方式更改了这些类,并添加了一个新类

public class Bid : ...
{
   ...

   [Required]
   public virtual TraderUser TraderUser { get; set; }
}

public class TraderUser : ...
{
   ...

   public int TraderCompanyId { get; set; }

   [ForeignKey("TraderCompanyId")]
   public virtual TraderCompany TraderCompany { get; set; }
}

public class TraderCompany : ...
{
   ...
}
Run Code Online (Sandbox Code Playgroud)

当我做更新数据库时,我收到以下错误

ALTER …

entity-framework-5

11
推荐指数
1
解决办法
9841
查看次数

MVC 5路由和可选参数

我有以下控制器和路由定义

[System.Web.Mvc.Route("users/{firstName?}/{lastName?}/{emailAddress?}/{pageSize:int=10}/{pageNumber:int=1}", Name = RouteNames.User_Listing)]
public ActionResult Index(string firstName = null, string lastName = null, string emailAddress = null, int pageNumber = 1, int pageSize = 10)
Run Code Online (Sandbox Code Playgroud)

我想要的是任何这些都是未定义或定义的,因此所有这些都是有效的

users/first/last/email
users/last/email/30/2
users/last/1
users
Run Code Online (Sandbox Code Playgroud)

问题是,MVC如何知道指定了哪些参数?它没有!

当我有这个链接

@Html.RouteLink("Maintain Users", RouteNames.User_Listing)
Run Code Online (Sandbox Code Playgroud)

它不会导航到此操作方法.我该怎么办?

asp.net-mvc-routing asp.net-mvc-5

11
推荐指数
2
解决办法
1万
查看次数

"不允许子操作执行重定向操作"

我有这个错误:

执行处理程序'System.Web.Mvc.HttpHandlerUtil + ServerExecuteHttpHandlerAsyncWrapper'的子请求时出错.

内部异常:

不允许子操作执行重定向操作.

知道为什么会这样吗?

顺便说一句,错误发生在这一行:

@Html.Action("Menu", "Navigation")
Run Code Online (Sandbox Code Playgroud)

导航控制器中的菜单操作如下所示:

public ActionResult Menu()
{
    return PartialView();
}
Run Code Online (Sandbox Code Playgroud)

c# asp.net-mvc-3

9
推荐指数
3
解决办法
2万
查看次数

在EF Database First项目中更新模型

我继承了一个使用Entity Framework Database First的项目.我正在尝试更新数据库时如何更新模型类,但我无法弄明白.到目前为止,我已经完成了一个名为Test的列到数据库中的表,然后在模型浏览器中我右键单击了.edmx文件并从数据库中选择了Update Model,然后按照出现的向导中的选项进行操作.现在,当我查看打开.edmx文件时呈现的数据库关系图时,我可以看到测试列已添加到表中.问题是相应的C#模型类没有更新.我不认为我必须手动更新它,因为文件顶部有此消息

//------------------------------------------------------------------------------
// <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)

所以问题是,如何更新此模型文件?我必须要做些什么才能做到这一点?

谢谢,

萨钦

edmx entity-framework-4 ef-database-first

9
推荐指数
1
解决办法
6853
查看次数

实体框架:无法创建类型为'System.Collections.Generic.IList`1'的常量值

这使我今天无法解决问题.我有这个简单的查询

var result =
    DataContext.Accommodations.Where(a => 
        (criteria.MinPrice == null || a.AccommodationRates.Any(r => r.From >= criteria.MinPrice)) &&
        (criteria.MaxPrice == null || a.AccommodationRates.Any(r => r.To <= criteria.MaxPrice)) &&
        (criteria.Locations == null || criteria.Locations.Count == 0 || a.AccommodationPlaceJoins.Any(j => criteria.Locations.Contains(j.Place.PlaceName)))
);
Run Code Online (Sandbox Code Playgroud)

此查询的最后一行导致我出现问题

(criteria.Locations == null ||
 criteria.Locations.Count == 0 ||
 a.AccommodationPlaceJoins.Any(j => criteria.Locations.Contains(j.Place.PlaceName)))
Run Code Online (Sandbox Code Playgroud)

它给出的错误是

无法创建类型为'System.Collections.Generic.IList`1'的常量值.在此上下文中仅支持原始类型(例如Int32,String和Guid').

我甚至没有尝试创建列表.我在这里尝试做的就是带回与一个地方相关的住宿(Place表中通过AccommodationPlaceJoin表链接到住宿表的地名)等于标准中的任何一个地名.Locations(属于IList类型).

我已经尝试将此行更改为此,但它不起作用.

(criteria.Locations == null ||
 criteria.Locations.Count == 0 ||
 a.AccommodationPlaceJoins.Any(j => criteria.Locations.Any(l => l == j.Place.PlaceName)))
Run Code Online (Sandbox Code Playgroud)

c# lambda linq-to-entities entity-framework-4

9
推荐指数
1
解决办法
2万
查看次数

在Jenkins管道中构建特定版本

我使用SVN作为我的源代码控制存储库,Jenkins作为我的CI工具.我使用Jenkins运行MSBuild脚本来进行实际的构建和部署.我还使用Jenkins Pipeline插件来管理下游项目的构建.

我的管道有问题.问题是,我已经对SVN进行了10次签到,结果发生了10次自动CI构建,结果管道显示了10次构建.现在,如果我想要把版本号5在管道中的下一个阶段我希望所有的代码到第五构建要建到下一个阶段,而是正在发生的事情是,最新的代码(建立10)一直在使用.

我不知道是否需要修改构建脚本或是否需要配置Jenkins或是否需要配置管道插件.有人知道吗?

如果您不知道管道插件的含义,请点击此处截图.

在此输入图像描述

svn msbuild msbuild-task jenkins jenkins-plugins

9
推荐指数
1
解决办法
1万
查看次数

从字符串中删除字母字符和空格

我有一个包含许多字符的字符串.我想删除A-Za-z和白色空间,剩下的就剩下了.最好的方法是什么?

这是我尝试过的

presaleEstimateHigh = Regex.Replace(presaleEstimateHigh, @"[A-Za-z]", string.Empty);
Run Code Online (Sandbox Code Playgroud)

但我还需要删除空白区域.

.net c#

9
推荐指数
1
解决办法
6477
查看次数

Simple Injector将硬编码值传递给构造函数

Simple Injector中,我可以执行以下操作:

container.RegisterSingle<IAuctionContext>(() => new AuctionContext(
    new Uri("http://localhost:60001/AuctionDataService.svc/")));
Run Code Online (Sandbox Code Playgroud)

我在这里做的是说,IAuctionContext找到它后,用这个新的替换它AuctionContext.问题是,通过调用RegisterSingle,只会使用一个实例AuctionContext.我希望它能够传递Uri如上所述的参数但不具有单个实例但每次都允许新实例.

这怎么可能?

c# dependency-injection ioc-container simple-injector

9
推荐指数
1
解决办法
5056
查看次数

实体框架SaveChanges()不更新数据库

var paymentAttempt = _auctionContext.PaymentAttempts.Where(o => o.Id == paymentAttemptId).SingleOrDefault();
if (paymentAttempt != null)
{
    paymentAttempt.PaymentAttemptStatusId = (int)PaymentAttemptStatus.Defunct;
    paymentAttempt.PaymentAttemptStatus = _auctionContext.PaymentAttemptStatuses.Where(pas => pas.Id == paymentAttempt.PaymentAttemptStatusId).First();

    var relevantWinningBidsTotalPrices = _auctionContext.GetWinningBidsTotalPricesForPaymentAttempt(paymentAttemptId).ToArray();

    foreach (var winningBid in relevantWinningBidsTotalPrices)
    {
        winningBid.Locked = false;
        _auctionContext.UpdateObject(winningBid);
    }
    _auctionContext.SaveChanges();
}
Run Code Online (Sandbox Code Playgroud)

在上面的代码之后

_auctionContext.SaveChanges();
Run Code Online (Sandbox Code Playgroud)

调用winningBid按预期更新但paymentAttempt不是.为什么是这样?真的很令人沮丧.也没有错误.如果像EF一样没有跟踪对象或类似的问题,我会发现无法发生,但是没有发生这样的错误.

c# entity-framework

9
推荐指数
2
解决办法
4万
查看次数