asp.net-mvc-5 相关问题

ASP.NET MVC 5是用于Web应用程序的ASP.NET Model-View-Controller平台的第五个主要版本。

<system.codedom>/<compilers> 在 MVC 5 的 web.config 中到底做了什么?

我准备将一堆项目从 .NET 4.0 + MVC 3 迁移到 .NET 4.5.2 + MVC5。 为了使这更容易,我创建了一个新的空白 MVC 项目来比较 DLL 引用和其他一些东西,例如 ...

回答 2 投票 0

jquery 将 null 传递给动作控制器参数甚至值不为 null

我在控制器中有 Action 方法如下 [HttpPost] 公共 ActionResult 上传文件(HttpPostedFileBase 文件,字符串文件夹名称) { 字符串文件夹路径 = "~/

回答 1 投票 0

ASP.NET MVC 控制器上传照片和保存文件夹路径

我使用的方法在其他服务器上有效。它可以在我的电脑上运行,但不能在我刚租用的服务器上运行。 公共 JsonResult SaveRegesterPhoto(字符串 mImage) { 如果(字符串。IsNullOrEmpty(mImage)) ...

回答 1 投票 0

SignInManager.ExternalSignInAsync 与 Facebook 总是返回失败

Google+ 有效,但 Facebook 总是返回失败。当我检查 loginInfo 时,它显示 authenticated = true。 这是 Statup.Auth.cs 中的代码 - 我包含了有效的 Google+ 代码。 普...

回答 4 投票 0

未找到视图“名称”或其母版,或者没有视图引擎支持搜索到的位置

我收到此错误消息,我看到的任何建议似乎都不适用;即所有视图、控制器和模型都在正确的文件夹中。 更多详情: 我有主人

回答 2 投票 0

如何从 asp.net mvc 5 将通知推送到适用于 IOS/android 的 flutter 应用程序?

我正在构建一个汽车租赁 flutter 应用程序来让用户预订汽车,我正在构建一个 asp.net 管理端来接受或拒绝它所以,我希望当管理员采取这个行动时......

回答 0 投票 0

无参数端点的 MVC5 [Route] 属性不起作用

我有一个带有 Angular 前端的 MVC 5 应用程序。 我在调用无参数端点时遇到问题。 MVC 应用程序有一个控制器,Angular 应用程序调用它来获取数据。 对于

回答 1 投票 0

如何在 ASP.NET MVC 5 的 EF 中使用 Begin Transaction?

我的项目有三层 应用核心 基础设施 用户界面 在 ApplicationCore 我有一个存储库接口: 公共接口 IRepository 其中 TEntity :类 { 列表<

回答 0 投票 0

布局页面“~/Views/Shared/index.cshtml”没有调用“RenderBody”方法

布局页面“~/Views/Shared/index.cshtml”没有调用“RenderBody”方法 执行当前 Web 请求期间发生未处理的异常。请查看堆栈...

回答 7 投票 0

从 LocalDB 切换到 SQL Server DB MVC5

我有一个带有个人身份验证的 MVC5 项目。 现在我想从 (localdb)\MSSQLLocalDB 移动到另一个 SQL Server 数据库。 我试图从此更改连接字符串: 数据来源...

回答 1 投票 0

转到控制器显示“无法找到匹配的控制器。”错误

在 VS 2015 中,对于我的 Web.API 项目,我通过 npm 从 nuget 安装了 MVC 5。 此安装在 Views 文件夹下添加了引用并生成了 web.config 文件。 我添加了新的控制器生成...

回答 7 投票 0

Emgu.CV.MatInvoke'抛出异常

DllNotFoundException:无法加载 DLL 'cvextern':找不到指定的模块。 (HRESULT 异常:0x8007007E) [HttpPost] 公共 ActionResult DetectFacesAndBlur(字符串图像...

回答 0 投票 0

如何使用 Kendo for jquery 将上传的图像文件绑定到 ASP.NET MVC 5 模型?

我已经准备好我能找到的关于这个主题的一切,但没有任何东西能解决我的问题。我对 Kendo 完全陌生(它的版本 2018.1.221 很旧),对 ASP.NET MVC 5 相对较新,而我的 jQu ...

回答 0 投票 0

MVC 显示仅有价值的模型属性?

好吧,所以我的模型包含 200 多个属性或字段,使用实体框架,这反映到数据库中有 1 行 200 列。在视图中显示此模型时,会喜欢...

回答 2 投票 0

如何使用 Swashbuckle 提供模型文档和示例值?

我使用 Web API 2 (MVC 5) 创建了一个 API 方法,如下所示: /// /// 导入给定组织的所有工作。该方法假定组织的所有... 我已经使用 Web API 2 (MVC 5) 创建了一个 API 方法,如下所示: /// <summary> /// Import all of the jobs for the given organisation. This method assumes that all of the organisation's active jobs are present in the jobs array. /// To delete a job, simply exclude it from the jobs array. To delete all of the jobs, pass an empty array /// </summary> /// <param name="org">Organisation Id, provided by Shopless team</param> /// <param name="jobs">Full list of jobs which should be imported, json array</param> /// <response code="200">Jobs list have been queued for import (includes validation errors if any)</response> /// <response code="401">Access to this organisation was denied</response> /// <response code="404">Invalid organisation id</response> [SwaggerResponse(HttpStatusCode.BadRequest)] [SwaggerResponse(HttpStatusCode.NotFound)] [SwaggerResponse(HttpStatusCode.Unauthorized)] [HttpPost] [Route("org/{org}/jobs/full-import")] public IHttpActionResult FullImport(long org, [FromBody] List<JobApiDto> jobs) { if (!ModelState.IsValid) { return BadRequest("Jobs array is invalid"); } else if (org < 1) { return NotFound("Invalid organisation id"); } else if (!((ClaimsPrincipal)User).HasReadWriteAccessToOrganisation(org)) { return Unauthorized("Access to this organisation was denied"); } _apiProductUploader.Upload(org, jobs, out string message); return Accepted(message); } 上述方法接受JobApiDto的列表: public class JobApiDto { /// <summary> /// Job Id (unique id assigned to the job by the API consumer) /// </summary> /// <example>e5f52dae-e008-49bd-898b-47b5f1a52f40</example> public string UniqueThirdPartyId { get; set; } /// <summary> /// Short description which will be displayed in search result /// </summary> /// <example>Competitive salary, great team, cutting edge technology!</example> public string Synopsis { get; set; } // more properties 这就是 Swagger 文档的样子: 当我展开OrganisationJobs动作时: 这是模型选项卡: 如您所见,控制器的 xml 文档为 API 方法生成了正确的描述,但我无法理解为什么我为模型提供的描述(即 JobApiDto)没有显示? 此外,当我单击“示例值”时,什么也没有发生。 感谢亚历山大指出这个答案。 我安装了 Swashbuckle.Examples Nuget 包。 (文档很棒。) 我不得不用以下方式注释控制器: [SwaggerRequestExample(typeof(JobApiDto), typeof(ListJobApiDtoExample), jsonConverter: typeof(StringEnumConverter))] 这就是控制器定义的样子: /// <summary> /// Import all of the jobs for the given organisation. This method assumes that all of the organisation's active jobs are present in the jobs array. /// To delete a job, simply exclude it from the jobs array. To delete all of the jobs, pass an empty array /// </summary> /// <param name="org">Organisation Id, provided by Shopless team</param> /// <param name="jobs">Full list of jobs which should be imported, json array</param> [SwaggerRequestExample(typeof(JobApiDto), typeof(ListJobApiDtoExample), jsonConverter: typeof(StringEnumConverter))] [SwaggerResponse(HttpStatusCode.OK, Description = "Jobs array has been queued for import", Type = typeof(ImportResponse))] [SwaggerResponseExample(HttpStatusCode.OK, typeof(ImportResponseExamples))] [SwaggerResponse(HttpStatusCode.BadRequest, "Jobs array is invalid")] [SwaggerResponse(HttpStatusCode.NotFound, "Invalid organisation id")] [SwaggerResponse(HttpStatusCode.Unauthorized, "Access to this organisation was denied")] [HttpPost] [Route("org/{org}/jobs/full-import")] public IHttpActionResult FullImport(long org, [FromBody] List<JobApiDto> jobs) { if (!ModelState.IsValid) { return BadRequest("Jobs array is invalid"); } else if (org < 1) { return NotFound("Invalid organisation id"); } else if (!((ClaimsPrincipal)User).HasReadWriteAccessToOrganisation(org)) { return Unauthorized("Access to this organisation was denied"); } _apiProductUploader.Upload(org, jobs, out ImportResponse importResponse); return Accepted(importResponse); } 这里是ListJobApiDtoExample的实现: public class ListJobApiDtoExample : IExamplesProvider { public object GetExamples() { return new JobApiDto() { UniqueThirdPartyId = "e5f52dae-e008-49bd-898b-47b5f1a52f40", CategoryId = 1183, Title = "Senior Software Developer", Description = "Example company is looking for a senior software developer... more details about the job", Reference = "", Synopsis = "Competitive salary, great team, cutting edge technology!", MinSalary = 120000, MaxSalary = 140000, SalaryPer = "Per annum", DisplaySalary = true, CustomSalaryText = "plus bonus", WorkType = "Full time", Location = "Wellington CBD", ContactName = "John Smith", ContactEmail = "[email protected]", ContactPhoneNumber = "021 123 456 789", ApplicationUrl = "", LogoUrl = "https://www.example-company.com/my-company-logo", YouTubeVideo = "https://www.youtube.com/watch?v=khb7pSEUedc&t=1s", StartDate = null, PostedAt = null }; } } 请注意,我还有一个 API 返回类型的示例,ImportResponse。与之前的模型类似,我在控制器上有这个注释: [SwaggerResponseExample(HttpStatusCode.OK, typeof(ImportResponseExamples))] 这是植入: public class ImportResponseExamples : IExamplesProvider { public object GetExamples() { return new ImportResponse() { Message = "Products are queued to be imported" }; } } 现在,文档正确显示了示例:

回答 1 投票 0

水晶报表报错:数据源对象无效

我正在尝试使用水晶报表打印学生证,但我所能得到的只是弹出此错误数据源对象无效。 伙计们请帮我检查一下这段代码......

回答 2 投票 0

ASP.NET MVC5 Bootstrap 3 Modal Form 未验证客户端并回发到页面

我有一个 MVC5 应用程序,我刚开始在上面做一些 Ajax。 我有一个带有按钮的页面,单击该按钮会打开一个带有来自另一个操作的表单的 Bootstrap 模式。然而,当那...

回答 2 投票 0

如何在 .net Framework 4.7.2 MVC web app 中使用 .net Standard 2 IFormFile 参考

我们正在努力将一些遗留的 .net 框架 4.7.2 网络应用程序转换为 .net 核心。我们正在使用 .net 标准库来允许我们的基础设施在我们获得网站之前得到更新

回答 1 投票 0

ASP.NET MVC 5 中通过 AsQueryable() 和 ToList() 获取数据的区别

我想知道这两种方法之间的确切区别是什么——以及我们什么时候需要这两种方法中的任何一种? 我想提高我的查询技能。

回答 0 投票 0

在 MVC 5 中使用 MathCaptcha

我正在运行 MVC5 并尝试在我的 Web 应用程序中实施 CAPTCHA。我安装了 CaptchaMvc.Mvc5(版本 1.5.0),当我尝试在我的视图中使用 HTMLHelper 时,它给了我一个红色波浪形...

回答 0 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.