Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/jpa/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 最大长度255阻止表单提交,尽管StringLength较长_C#_.net_Asp.net Mvc - Fatal编程技术网

C# 最大长度255阻止表单提交,尽管StringLength较长

C# 最大长度255阻止表单提交,尽管StringLength较长,c#,.net,asp.net-mvc,C#,.net,Asp.net Mvc,我正在尝试创建一个表单,允许用户向SQL Server数据库提交新记录,该数据库最终将显示在站点上。我有一个Description字段,在服务器端是一个nvarchar(max)。在我的模型中,我指定的字符串长度超过255(即5001000),我使用了StringLength(Int32.MaxLength)。我曾尝试禁用客户端验证,将验证完全从输入中排除,但没有成功。但是,当在本地运行代码时,它会按预期运行并允许表单提交,但是当通过FTP(使用相同的代码)部署到live GoDaddy站点时,

我正在尝试创建一个表单,允许用户向SQL Server数据库提交新记录,该数据库最终将显示在站点上。我有一个
Description
字段,在服务器端是一个nvarchar(max)。在我的模型中,我指定的字符串长度超过255(即5001000),我使用了
StringLength(Int32.MaxLength)
。我曾尝试禁用客户端验证,将验证完全从输入中排除,但没有成功。但是,当在本地运行代码时,它会按预期运行并允许表单提交,但是当通过FTP(使用相同的代码)部署到live GoDaddy站点时,它仍然抛出MaxLength验证错误
字段描述必须是最大长度为255的字符串。

野猪
名称空间
{
使用制度;
使用System.Collections.Generic;
使用System.ComponentModel.DataAnnotations;
使用System.ComponentModel.DataAnnotations.Schema;
使用System.Data.Entity.Spatial;
公猪
{
[System.Diagnostics.CodeAnalysis.SuppressMessage(“Microsoft.Usage”,“CA2214:DoNotCallOverridableMethodsInConstructors”)]
公猪
{
SellingPoints=newhashset();
}
[关键]
[列(TypeName=“numeric”)]
公共十进制Boar_Id{get;set;}
[StringLength(255)]
公共字符串名称{get;set;}
公共日期时间?生成的{get;set;}
公共int?LitterSize{get;set;}
公共整数?价格{get;set;}
公共布尔?担保结算{get;set;}
[StringLength(255)]
公共字符串测试{get;set;}
[StringLength(255)]
公共字符串名称空间{get;set;}
[StringLength(255)]
公共字符串Sire{get;set;}
[StringLength(255)]
公共字符串{get;set;}
[StringLength(255)]
公共字符串Dam{get;set;}
[StringLength(255)]
公共字符串DamFull{get;set;}
[StringLength(255)]
公共字符串{get;set;}
公共整数?顺序{get;set;}
公共布尔?特征{get;set;}
public int?FeaturedOrder{get;set;}
[StringLength(255)]
公共字符串EarNotch{get;set;}
[StringLength(255)]
公共字符串RegNum{get;set;}
[StringLength(255)]
公共字符串TestData{get;set;}
[StringLength(255)]
公共字符串BredBy{get;set;}
[StringLength(255)]
{get;set;}拥有的公共字符串
[长度(500)]
公共字符串说明{get;set;}
公共日期时间?CreateDate{get;set;}
[System.Diagnostics.CodeAnalysis.SuppressMessage(“Microsoft.Usage”,“CA2227:CollectionPropertiesShouldBreadOnly”)]
公共虚拟ICollection SellingPoints{get;set;}
}
}
Create.cshtml(朝向底部:Description字段)
@model shipleyshough.Boar
@{
ViewBag.Title=“创建”;
}
创造
@使用(Html.BeginForm())
{
@Html.AntiForgeryToken()
野猪

@Html.ValidationSummary(true,“,new{@class=“text danger”}) @*@LabelFor(model=>model.Boar_Id,htmlAttributes:new{@class=“controllabel col-md-2”})*@ 公猪ID @*@EditorFor(model=>model.Boar_Id,new{htmlAttributes=new{placeholder=“Ex:1”,@class=“form control”})*@ @Html.ValidationMessageFor(model=>model.Boar_Id,“,new{@class=“text danger”}) @LabelFor(model=>model.Name,htmlAttributes:new{@class=“controllabel col-md-2”}) @EditorFor(model=>model.Name,new{htmlAttributes=new{placeholder=“Ex:Gavin”,@class=“form control”}) @Html.ValidationMessageFor(model=>model.Name,“,new{@class=“text danger”}) @LabelFor(model=>model.Farrowed,htmlAttributes:new{@class=“controllabel col-md-2”}) @EditorFor(model=>model.Farrowed,new{htmlAttributes=new{placeholder=“Ex:2015-07-10”,@class=“form control”}) @Html.ValidationMessageFor(model=>model.Farrowed,“,new{@class=“text danger”}) @LabelFor(model=>model.LitterSize,htmlAttributes:new{@class=“controllabel col-md-2”}) @EditorFor(model=>model.LitterSize,new{htmlAttributes=new{placeholder=“Ex:5”,@class=“form control”}) @Html.ValidationMessageFor(model=>model.litersize,“,new{@class=“text danger”}) @LabelFor(model=>model.Price,htmlAttributes:new{@class=“controllabel col-md-2”}) @EditorFor(model=>model.Price,new{htmlAttributes=new{placeholder=“Ex:500”,@class=“form control”}) @Html.ValidationMessageFor(model=>model.Price,“,new{@class=“text danger”}) @LabelFor(model=>model.guarantedSettle,htmlAttributes:new{@class=“controllabel col-md-2”}) @EditorFor(model=>model.GuaranteedSettle) @Html.ValidationMessageFor(model=>model.GuaranteedSettle,“,new{@class=“text danger”}) @Html.LabelFor(model=>model.StressTest,
namespace ShipleySwine
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel.DataAnnotations;
    using System.ComponentModel.DataAnnotations.Schema;
    using System.Data.Entity.Spatial;

    public partial class Boar
    {
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
        public Boar()
        {
            SellingPoints = new HashSet<SellingPoint>();
        }

        [Key]
        [Column(TypeName = "numeric")]
        public decimal Boar_Id { get; set; }

        [StringLength(255)]
        public string Name { get; set; }

        public DateTime? Farrowed { get; set; }

        public int? LitterSize { get; set; }

        public int? Price { get; set; }

        public bool? GuaranteedSettle { get; set; }

        [StringLength(255)]
        public string StressTest { get; set; }

        [StringLength(255)]
        public string NameNoSpaces { get; set; }

        [StringLength(255)]
        public string Sire { get; set; }

        [StringLength(255)]
        public string SireFull { get; set; }

        [StringLength(255)]
        public string Dam { get; set; }

        [StringLength(255)]
        public string DamFull { get; set; }

        [StringLength(255)]
        public string Breed { get; set; }

        public int? Order { get; set; }

        public bool? Featured { get; set; }

        public int? FeaturedOrder { get; set; }

        [StringLength(255)]
        public string EarNotch { get; set; }

        [StringLength(255)]
        public string RegNum { get; set; }

        [StringLength(255)]
        public string TestData { get; set; }

        [StringLength(255)]
        public string BredBy { get; set; }

        [StringLength(255)]
        public string OwnedBy { get; set; }

        [StringLength(500)]
        public string Description { get; set; }

        public DateTime? CreateDate { get; set; }

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
        public virtual ICollection<SellingPoint> SellingPoints { get; set; }
    }
}

@model ShipleySwine.Boar



@{
    ViewBag.Title = "Create";
}

<div class="container backgroundcolor">
    <h2>Create</h2>


    @using (Html.BeginForm())
    {
        @Html.AntiForgeryToken()

        <div class="form-horizontal">
            <h4>Boar</h4>
            <hr />
            @Html.ValidationSummary(true, "", new { @class = "text-danger" })
            <div class="form-group">
                @*@Html.LabelFor(model => model.Boar_Id, htmlAttributes: new { @class = "control-label col-md-2" })*@
                <label class="control-label col-md-2" for="Boar_id">Boar ID</label>
                <div class="col-md-10">
                    <input name="Boar_id" class="form-control" value="@ViewBag.BoarId" readonly="readonly" />
                    @*@Html.EditorFor(model => model.Boar_Id, new { htmlAttributes = new { placeholder = "Ex: 1" , @class = "form-control" } })*@
                    @Html.ValidationMessageFor(model => model.Boar_Id, "", new { @class = "text-danger" })
                </div>
            </div>

            <div class="form-group">
                @Html.LabelFor(model => model.Name, htmlAttributes: new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.EditorFor(model => model.Name, new { htmlAttributes = new { placeholder = "Ex: Gavin", @class = "form-control" } })
                    @Html.ValidationMessageFor(model => model.Name, "", new { @class = "text-danger" })
                </div>
            </div>

            <div class="form-group">
                @Html.LabelFor(model => model.Farrowed, htmlAttributes: new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.EditorFor(model => model.Farrowed, new { htmlAttributes = new { placeholder = "Ex: 2015-07-10", @class = "form-control" } })
                    @Html.ValidationMessageFor(model => model.Farrowed, "", new { @class = "text-danger" })
                </div>
            </div>

            <div class="form-group">
                @Html.LabelFor(model => model.LitterSize, htmlAttributes: new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.EditorFor(model => model.LitterSize, new { htmlAttributes = new { placeholder = "Ex: 5", @class = "form-control" } })
                    @Html.ValidationMessageFor(model => model.LitterSize, "", new { @class = "text-danger" })
                </div>
            </div>

            <div class="form-group">
                @Html.LabelFor(model => model.Price, htmlAttributes: new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.EditorFor(model => model.Price, new { htmlAttributes = new { placeholder = "Ex: 500", @class = "form-control" } })
                    @Html.ValidationMessageFor(model => model.Price, "", new { @class = "text-danger" })
                </div>
            </div>

            <div class="form-group">
                @Html.LabelFor(model => model.GuaranteedSettle, htmlAttributes: new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    <div class="checkbox">
                        @Html.EditorFor(model => model.GuaranteedSettle)
                        @Html.ValidationMessageFor(model => model.GuaranteedSettle, "", new { @class = "text-danger" })
                    </div>
                </div>
            </div>

            <div class="form-group">
                @Html.LabelFor(model => model.StressTest, htmlAttributes: new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.EditorFor(model => model.StressTest, new { htmlAttributes = new { placeholder = "Ex: Negative, Carrier", @class = "form-control" } })
                    @Html.ValidationMessageFor(model => model.StressTest, "", new { @class = "text-danger" })
                </div>
            </div>

            <div class="form-group">
                @Html.LabelFor(model => model.NameNoSpaces, htmlAttributes: new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.EditorFor(model => model.NameNoSpaces, new { htmlAttributes = new { placeholder = "Ex: GavinNoSpaces", @class = "form-control" } })
                    @Html.ValidationMessageFor(model => model.NameNoSpaces, "", new { @class = "text-danger" })
                </div>
            </div>

            <div class="form-group">
                @Html.LabelFor(model => model.Sire, htmlAttributes: new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.EditorFor(model => model.Sire, new { htmlAttributes = new { placeholder = "Ex: Daddy Boar", @class = "form-control" } })
                    @Html.ValidationMessageFor(model => model.Sire, "", new { @class = "text-danger" })
                </div>
            </div>

            <div class="form-group">
                @Html.LabelFor(model => model.SireFull, htmlAttributes: new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.EditorFor(model => model.SireFull, new { htmlAttributes = new { placeholder = "Ex: Daddy Boar Full Name", @class = "form-control" } })
                    @Html.ValidationMessageFor(model => model.SireFull, "", new { @class = "text-danger" })
                </div>
            </div>

            <div class="form-group">
                @Html.LabelFor(model => model.Dam, htmlAttributes: new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.EditorFor(model => model.Dam, new { htmlAttributes = new { placeholder = "Ex: Mommy Boar", @class = "form-control" } })
                    @Html.ValidationMessageFor(model => model.Dam, "", new { @class = "text-danger" })
                </div>
            </div>

            <div class="form-group">
                @Html.LabelFor(model => model.DamFull, htmlAttributes: new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.EditorFor(model => model.DamFull, new { htmlAttributes = new { placeholder = "Ex: Mommy Boar Full Name", @class = "form-control" } })
                    @Html.ValidationMessageFor(model => model.DamFull, "", new { @class = "text-danger" })
                </div>
            </div>

            <div class="form-group">
                @Html.LabelFor(model => model.Breed, htmlAttributes: new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.EditorFor(model => model.Breed, new { htmlAttributes = new { placeholder = "Ex: Yorkshire, Berkshire,Duroc", @class = "form-control" } })
                    @Html.ValidationMessageFor(model => model.Breed, "", new { @class = "text-danger" })
                </div>
            </div>

            <div class="form-group">
                @Html.LabelFor(model => model.Order, htmlAttributes: new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.EditorFor(model => model.Order, new { htmlAttributes = new { placeholder = "Ex: 5", @class = "form-control" } })
                    @Html.ValidationMessageFor(model => model.Order, "", new { @class = "text-danger" })
                </div>
            </div>

            <div class="form-group">
                @Html.LabelFor(model => model.Featured, htmlAttributes: new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    <div class="checkbox">
                        @Html.EditorFor(model => model.Featured)
                        @Html.ValidationMessageFor(model => model.Featured, "", new { @class = "text-danger" })
                    </div>
                </div>
            </div>

            <div class="form-group">
                @Html.LabelFor(model => model.FeaturedOrder, htmlAttributes: new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.EditorFor(model => model.FeaturedOrder, new { htmlAttributes = new { placeholder = "Ex: 5", @class = "form-control" } })
                    @Html.ValidationMessageFor(model => model.FeaturedOrder, "", new { @class = "text-danger" })
                </div>
            </div>

            <div class="form-group">
                @Html.LabelFor(model => model.EarNotch, htmlAttributes: new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.EditorFor(model => model.EarNotch, new { htmlAttributes = new { placeholder = "Ex: E.N.: 23-5", @class = "form-control" } })
                    @Html.ValidationMessageFor(model => model.EarNotch, "", new { @class = "text-danger" })
                </div>
            </div>

            <div class="form-group">
                @Html.LabelFor(model => model.RegNum, htmlAttributes: new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.EditorFor(model => model.RegNum, new { htmlAttributes = new { placeholder = "Reg #: 490946005", @class = "form-control" } })
                    @Html.ValidationMessageFor(model => model.RegNum, "", new { @class = "text-danger" })
                </div>
            </div>

            <div class="form-group">
                @Html.LabelFor(model => model.TestData, htmlAttributes: new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.EditorFor(model => model.TestData, new { htmlAttributes = new { placeholder = "158 days to 250# 0.51 BF 9.38 LE", @class = "form-control" } })
                    @Html.ValidationMessageFor(model => model.TestData, "", new { @class = "text-danger" })
                </div>
            </div>

            <div class="form-group">
                @Html.LabelFor(model => model.BredBy, htmlAttributes: new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.EditorFor(model => model.BredBy, new { htmlAttributes = new { placeholder = "Bred By: Farrer Stock Farm (IN)", @class = "form-control" } })
                    @Html.ValidationMessageFor(model => model.BredBy, "", new { @class = "text-danger" })
                </div>
            </div>

            <div class="form-group">
                @Html.LabelFor(model => model.OwnedBy, htmlAttributes: new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.EditorFor(model => model.OwnedBy, new { htmlAttributes = new { placeholder = "Owned By: Shipley Swine Genetics, Snyder Berks and Austin Lane", @class = "form-control" } })
                    @Html.ValidationMessageFor(model => model.OwnedBy, "", new { @class = "text-danger" })
                </div>
            </div>

            <div class="form-group">
                @Html.LabelFor(model => model.Description, htmlAttributes: new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.EditorFor(model => model.Description, new { htmlAttributes = new { placeholder = "Add something here", @class = "form-control" } })

                    @Html.ValidationMessageFor(model => model.Description, "", new { @class = "text-danger" })
                </div>
            </div>

            <div class="form-group">
                <div class="col-md-offset-2 col-md-10 text-center">
                    <input type="submit" value="Create" class="btn btn-primary" />
                </div>
            </div>
        </div>
    }

    <div>
        @Html.ActionLink("Back to List", "Index", "Boars")
    </div>
</div>

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}