草庐IT

asp.net-core

全部标签

c# - ASP.Net MVC3中如何实现打印

作为我在给定项目列表中的当前任务的一部分,用户可以选择其中的一些项目并调用“打印”不选择的项目。对于每个选定的项目,我们需要打印详细信息。它类似于在销售系统中打印选定项目的发票。我已经创建了一个局部View来写入每条记录的详细信息,但我不确定如何根据我的要求使用它。我可以在document.ready上调用jQueryprint来实现我的要求吗?正如@Levib所建议的,在我的PrintView中调用部分View。而PrintView的document.reay函数就是在调用window.print。但是当我尝试调用“打印”时,我看不到打印对话框。这是我的看法,@sectionStyl

c# - .net 中的 IL 和堆栈实现?

我写了一个简单的程序来检查IL的工作原理:voidMain(){inta=5;intb=6;if(aIL:IL_0000:ldc.i4.5IL_0001:stloc.0IL_0002:ldc.i4.6IL_0003:stloc.1IL_0004:ldloc.0IL_0005:ldloc.1IL_0006:bge.sIL_0012IL_0008:ldstr"333"IL_000D:callSystem.Console.WriteIL_0012:callSystem.Console.ReadLine我正在尝试了解实现效率:在第1行(IL代码)它将值5压入堆栈(4个字节,即int32)在第2

c# - 在没有 @HTML.Beginform 的情况下发布表单并在 asp.net MVC 中使用 Jquery(ajax)

如何在不使用@HTML.Beginform而改用JQueryAjax的情况下填写表单?现在我尝试了:varpostData={form1:username,form2:password};$.ajax({type:"POST",url:'/Controller/Method',data:postData,dataType:"json",traditional:true});但是在发布之后,浏览器没有导航到正确的View。当然,我在Controller中正确地返回了View()。使用Fiddler我看到它已正确发布并且响应也正确......我必须使用@HTML.Beginform还是可以

c# - 如何在 .net 3.5 中获得 Task<T> 的等价物?

我有一些代码正在使用Task它会在短时间内延迟从串行读取操作返回结果,如下所示:voidReturnResponseAfterAShortDelay(){if(delayedResponseCancellationTokenSource!=null)delayedResponseCancellationTokenSource.Cancel();//Cancelanypendingoperationsandstartanewone.delayedResponseCancellationTokenSource=newCancellationTokenSource();log.InfoFor

c# - 上传和查看文件 ASP.NET MVC 5

我有这个代码:[HttpPost]publicActionResultCreate(KnowledgebaseKB,HttpPostedFileBasefile){varKBFilePath="";if(ModelState.IsValid){if(file.ContentLength>0){varfileName=Path.GetFileName(KB.KnowledgebaseTitle);varpath=Path.Combine(Server.MapPath("~/Resources/KBArticles"),fileName+".pdf");KBFilePath=path;fi

c# - 在 Json.NET 序列化中忽略基类属性

我有以下类结构:[JsonObject]publicclassPolygon:IEnumerable{publicListVertices{get;set;}publicAxisAlignedRectangleEnvelope{get;set;}}publicclassAxisAlignedRectangle:Polygon{publicdoubleLeft{get;set;}...}我正在序列化Polygon类,但是当我这样做时,我得到一个JsonSerializationException,以及消息Selfreferencingloopdetectedforproperty'Env

c# - 与 ASP.net 5 MVC 6 中的错误处理混淆

我想要1个错误页面,根据提供的查询字符串向用户显示略有不同的错误消息。我在创建新的asp.net5项目时注意到Startup.cs文件中的以下代码。if(env.IsDevelopment()){app.UseBrowserLink();app.UseDeveloperExceptionPage();}else{app.UseExceptionHandler("/Home/Error");}我已经能够让它在发生异常时显示正确的错误页面。我的问题是它似乎只捕获我的应用程序中未处理的错误,即状态代码始终为500。这个对吗?要处理404错误,我使用以下代码:app.UseStatusCode

c# - 无法在 .net 核心中发布二进制文件

我正在尝试自行托管一个.netcoreMVC应用程序。它适用于所有.cs文件。当我通过命令窗口发布它(dotnetpublish-fnetcoreapp1.0-crelease)时,它显示以下错误:Noexecutablefoundmatching"bower"我什至尝试使用VS发布。它生成二进制文件。但是当我在命令提示符下执行dotnetrun时,我收到此错误消息:projectfiledoesnotexist'project.json'谁能建议如何使用二进制文件进行自托管? 最佳答案 从命令行运行dotnetpublish命令时

c# - 将 CSS 类添加到 TagHelper 中的 html 元素

在ASP.NETCoreView中,我有以下内容:我是一个带有以下TagHelper的TagHelper:[HtmlTargetElement("div",Attributes=MessageName)]publicclassMessageTagHelper:TagHelper{privateconstStringMessageName="message";[HtmlAttributeName(MessageName)]publicStringMessage{get;set;}[HtmlAttributeNotBound,ViewContext]publicViewContextVie

c# - 如何在 EF Core 中查询多对多关系

我正在为Web项目使用.NETCore和EFCore。我正在努力如何查询多对多关系。这是我的模型的样子:publicclassBegrip{publicintID{get;set;}publicstringName{get;set;}publicstringDesc{get;set;}[Url]publicstringURL{get;set;}publicICollectionCategories{get;set;}}publicclassCategory{publicintID{get;set;}publicstringName{get;set;}publicICollectionB