Tag: asp.net mvc

从客户端MVC4检测到一个潜在危险的Request.Form值

插入带有“<”的记录时出现此错误。 如何通过在其中插入带有“<”的字符串来解决此错误。 我正在使用实体框架。 此列的数据类型为nvarchar。 提前致谢。

无法将复杂对象传递给另一个Action方法

我正在尝试使用TempData将对象传递给另一个操作方法。 控制器不是重定向到操作方法,而是使用URL中的当前操作方法为我提供白屏。 如果我注释掉将对象传递给TempData的行,它会正确地重定向。 我的对象太复杂了吗? 是否有另一种方法将复杂对象传递给另一个操作方法? 我将对象传递给TempData的地方: public async Task UploadFile(IFormFile file) { if (file == null || file.Length == 0) return Content(“file not selected”); else { var path = Path.Combine( Directory.GetCurrentDirectory(), “wwwroot”, “processes.json”); using (var stream = new FileStream(path, FileMode.Create)) { await file.CopyToAsync(stream); } RetrieveModels rm = rm = new RetrieveModels(path); List foundList = new […]

代码优先迁移过程:我错过了哪个部分?

我的步骤: 1)使用查询在SSMS中创建我的数据库 /* Execute in SQL Server Management Studio prior to building data model(s) */ CREATE DATABASE snakedb; GO USE snakedb; /* Create table of scores of games played. Every game will have a score recorded, but there will only be a corresponding name if the user enters one */ CREATE TABLE Scores ( id […]

使用JSON.Net序列化数据的问题

我在我的应用程序中使用Kendo Scheduler使用Web Api从我的数据库中提取数据。 我创建了一个Web Api函数,并在那里硬编码了一些数据,以确保Kendo Scheduler可以读取我的数据。 这是我的Api函数代码: [Route(“api/v1/Events/GetPersonalEvents”, Name = “ApiEventsGetPersonalEvents”)] [HttpGet] public DataSourceResult GetPersonalEvents([System.Web.Http.ModelBinding.ModelBinder(typeof(WebApiDataSourceRequestModelBinder))]DataSourceRequest request) { var q = new ViewModels.Events.EventViewModel(); q.Id = 1; q.Title = “This is a test”; q.Start = DateTime.Now; q.End = DateTime.Now.AddHours(1); q.Description = “Test entry”; var list = new List(); list.Add(q); return list.ToDataSourceResult(request); } Kendo Scheduler没有在日历上显示任何内容。 使用Fiddler,我能够看到Kendo Scheduler正在调用我的API而我的API正在返回数据。 这是发送的JSON: […]

LINQ错误初始化成员声明符无效

我是一个相当初级的C#开发人员,请原谅我,如果这是微不足道的,但我在下面指出的代码行中提出了这个错误“无效的初始化成员声明符”。 有人可以解释这意味着什么,我如何解决/实现这个结果? 我的所有数据注释都已在PODetail中应用一次,这就是为什么我不想在这里重复这些属性。 public class PODetailsListViewModel : IViewModelList, IEntity { public int Id { get; set; } public string EntityDescription { get { return this.Id.ToString(); } } public PODetail PODetail { get; set; } public IEnumerable ConvertClassToViewModel(IEnumerable poDetails) { IEnumerable contactGrid = from l in poDetails.ToList() select new PODetailsListViewModel() { Id = l.Id, PODetail.POHeaderId = […]

如何忽略MetadataType属性中缺少的字段?

我有映射到ViewModels的DTO。 为了避免必须管理validation属性(和其他属性),我想在单个类上为所有属性编写validation属性,并在我的ViewModel上重用它。 但是,当我尝试在没有DTO的所有属性的ViewModel上使用元数据时(所有这些都属于……),它给了我一个System.InvalidOperationExceptionexception。 例外: Le type de métadonnées associé pour le type ‘MyProject.EntityViewModel’ contient les propriétés ou champs inconnus suivants : AnotherProperty. Vérifiez que les noms de ces membres correspondent aux noms des propriétés du type principal. 谷歌翻译: The type associated metadata for type ‘MyProject.EntityViewModel’ contains the following unknown properties or fields: AnotherProperty. Verify that […]

在模型中保存模型

所以,我有这个由ID Name和DataType定义的Property类。 DataType已填充静态值,并用作下拉列表。 现在,当用户从列表中选择某个值时, List值准确无误,应用程序会打开其他文本框和按钮,以填充该列表。 模特就是这样的。 物业模型 public class Property { public int ID {get; set;} public string Name {get; set;} public int DTypeID {get; set;} public virtual DType DTypes {get; set;} } 列表模型 public class DList { public int ID {get; set;} public int PropertyID {get; set;} public string ListValue {get; set;} } 这就是我到目前为止所做的。 […]

ASP.Net MVC长期运行流程

我要求为不同的财务期制作报告屏幕。 由于这是一个包含大量规则的相当大的数据集,因此该过程可能需要很长时间才能运行(一些报告返回的时间超过一小时)。 在MVC中处理这种情况的最佳方法是什么? 我担心: 屏幕锁定 性能 可用性 请求超时

ASP.NET MVC3 Razor在模型中查询(foreach中的foreach)

我在View中遇到了一个问题,从不同的实体中提取数据。 基本上我有一个桥接实体CategoryProduct,它将Category和Product数据汇集在一起​​。 我想最终展示的是产品清单以及每种产品 – 它们的类别。 然而,我完全停留在如何使最后一部分 – 显示类别 – 发生。 这是我模型的代码 – public class Product { public int ProductId { get; set; } public string Title { get; set; } public virtual ICollection CategoryProducts { get; set; } } public class CategoryProduct { public int CategoryProductID { get; set; } public int CategoryId { get; […]

在ASP.Net MVC 5应用程序中使用多个ASP Identity 2.0

我有一个带有管理区域的Web应用程序,用于管理内容,但该站点的其余部分目前由ASP身份保护,该身份validation我的公共用户。 现在我需要对一些内部用户进行身份validation以访问管理区域。 这可能吗?