草庐IT

index_name

全部标签

c# - "The type or namespace name ' 使用 ' could not be found"路由 "attribute routing"

只是试图将一些代码从一个工作项目拼接到另一个。“from”项目使用“属性路由”,您可以在WebAPIController模块中嵌入[Route(…)]指令来指示应该将哪个HTTP消息路由到哪个服务例程。在“from”项目中工作正常,但在“to”项目中我收到构建错误“找不到类型或namespace名称‘Route’(是否缺少using指令或程序集引用?)"我已经尝试将“from”项目中的所有using语句基本上复制到“to”项目中,但这没有明显效果。没有任何MS文档表明需要NuGet包(甚至是using语句)。这两个项目都应该是ASP.NETMVC4。(是的,我用config.MapHt

c# - 无法添加类型为 'filter' 且唯一键属性 'name' 设置为 'ASP.Net_4.0_64bit' 的重复集合条目

我遇到这个问题已经有一段时间了。当我打开一个指向我的本地主机的asp.net页面时,就会发生这种情况。我正在运行带有visualstudio2012和iis7.5的Windows2008r2。它显示的配置源是这样的。:1451:1452:1453:它表明它在第1452行出错。最初,这是inetsrv32位和64位位置的applicationHost.config文件中的一个问题。我进去并删除了重复的4.0条目,它工作了好几个月。然后它又开始抛出这个错误。那时我刚刚完全重新安装了IIS,我的应用程序又开始工作了。此错误再次开始出现,我再次执行了IIS的完全重新安装,但这次没有帮助,我的应

c# - WebApi 服务中的 [FromUri] 属性忽略了 DataMember 的 Name 属性

我们正在使用Asp.NetWebApi创建RestService。但由于某种原因,当尝试使用[FromURI]属性反序列化复杂属性时,Name属性在DataMember属性中被忽略。例如我们可能有:方法:publicIHttpActionResultGet([FromUri]Useruser)型号:[DataContract]publicclassUser{[DataMember(Name="username")]publicstringUsername{get;set;}[DataMember(Name="isActive",IsRequired=false)]publicbool?

c# - "Assembly Same Simple Name already been imported"错误

这是一个CLR项目。我正在导入两个同名的DLL文件,quizz.dll(我将旧版本重命名为legacyquizz.dll),并将新版本包含为quizz.dll到遗留转换器测试项目。(正在测试的遗留转换器项目仅导入旧的quizz.dll)。这是我遇到的错误。..Anassemblywiththesamesimplename'Quizz,Version=2.0.0.1,Culture=neutral,PublicKeyToken=nullhasalreadybeenimported.Tryremovingoneofthereferencesorsignthemtoenableside-by

c# - 尝试打开 telerik 报告时出现 "Value cannot be null. Parameter name: instance"错误

在我的解决方案中,我有telerik报告,当尝试在VisualStudio2010设计器中打开它们时,我收到此错误:Valuecannotbenull.Parametername:instanceCallStackatSystem.ComponentModel.TypeDescriptor.AddAttributes(Objectinstance,Attribute[]attributes)atMicrosoft.VisualStudio.Design.VSDesignSurface.CreateDesigner(IComponentcomponent,BooleanrootDesig

c# - 为什么 List<T> 出现 "Index was out of range"异常而不是数组?

当我初始化数组并使用索引器访问元素时,效果很好:object[]temp=newobject[5];temp[0]="bar";现在我希望同样适用于List,假设您可以通过将容量传递给构造函数来初始化它:Listtemp=newList(5);temp[0]="bar";然而,最后一行抛出以下异常:Indexwasoutofrange.Mustbenon-negativeandlessthanthesizeofthecollection为什么List会发生这种情况类型,但不是数组?由于数组只是CLR集合的较低级别抽象,那么为什么会出现此异常?原创question通过AwaisMahmo

c# - ASP.net Web API : change class name when serializing

我有一个产品的数据传输对象类publicclassProductDTO{publicGuidId{get;set;}publicstringName{get;set;}//Otherproperties}当Asp.net序列化JSON(使用JSON.NET)或XML中的对象时,它会生成ProductDTO对象。但是,我想在序列化期间更改名称,从ProductDTO到Product,使用某种属性:[Name("Product")]publicclassProductDTO{[Name("ProductId")]publicGuidId{get;set;}publicstringName{

c# - Nancy:从 "/"提供静态内容(例如 index.html)?

我正在尝试使用Nancy制作单页Web应用程序。因此,我希望我的根URL提供一个纯.html文件,没有任何View逻辑或任何内容。我试过了Get["/"]=parameters=>Response.AsHtml("content/index.html")但是没有AsHtml.我尝试了一个自定义Bootstrapconventions.StaticContentsConventions.Add(StaticContentConventionBuilder.AddFile("/",@"content/index.html"));但显然它认为“/”不是文件-Nancy给了我一个目录列表htt

c# - SQL 服务器 : invalid object name in query execution

我正在尝试执行Insert语句,但一直收到Invalidobjectname错误。这是我的代码:publicstringaddNewComment(intuserID,intpageID,stringtitle,stringcomment){stringquery="INSERTINTOdbo.nokernok_kommentarer(userID,pageID,commentTitle,comment)"+"VALUES("+userID+","+pageID+",'"+title+"','"+comment+"')";adapter.InsertCommand=newSqlComm

c# - 如何从根 url 重定向到/swagger/ui/index?

我有一个安装了Swashbuckle的WebApi项目。在默认设置中,我必须在浏览器中打开http://localhost:56131/swagger/ui/index以查看我的操作描述和测试页面。我希望它可以从站点的根目录访问:http://localhost:56131/。我怎样才能做到这一点? 最佳答案 受thisanswertosimilarquestion影响,稍作修改的代码:publicclassWebApiConfig{publicstaticvoidConfigure(IAppBuilderapp){varhttpC