MVC3 のフォーム投稿データに問題があります。ローカルでは、フォームは正常に POST されますが、ライブ サーバーでは、大量の投稿データがある場合、成功ページではなく 404 が表示されます。データは、POST に含まれるモデルから取得されます。多くの場合、そこには多くのデータがあり、そのうちのいくつかを使用しています。web.config の設定を変更することを検討しましたが、これは役に立ちませんでした。ここに私のコードのいくつかのスニペットがあります:
景色:
@using (Html.BeginForm("Bookmarked", "Bookmarklet", Model, FormMethod.Post))
{
<div class="form">
@Html.ValidationSummary(false)
@Html.TextBoxFor(a => a.Url, new { @class = "hidden" })
@Html.TextBoxFor(a => a.SelectedImage, new { @class = "selected-image hidden" })
<div class="form-left">
<div class="row">
<label>
Name:
</label>
@Html.TextBoxFor(a => a.Name, new { @class = "textbox" })
@Html.ValidationMessageFor(a => a.Name, null, new { style = "display:none" })
</div>
<div class="row">
<label>
Tags:
</label>
@Html.TextBoxFor(a => a.Tags, new { @class = "textbox tb-tags", @placeholder = "", onKeyUp = "submitForm(event)" })
</div>
<div class="row">
<br />
<label>
</label><a href="javascript:document.forms[0].submit()" class="button fl"><span>Bookmark</span></a>
</div>
</div>
// The controller
[HttpPost]
public ActionResult Bookmarked(BookmarkModel initialState, BookmarkModel model)
{
try
{
HttpCookie cookie = Request.Cookies["UserGuid"];
HttpCookie cookie2 = Request.Cookies["Username"];
if (cookie != null && cookie2 != null)
{
//do stuff with model data received from the View that the POST comes from
da.Save(model.Name, cookie.Value);
return View();
}
else
throw new Exception("Error saving, please try again");
}
catch (Exception ex)
{
ModelState.AddModelError("", ex.Message);
return Bookmark(model);
}
}
// web.config
<system.web>
<httpRuntime maxUrlLength="10999" maxQueryStringLength="2097151" />
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</assemblies>
</compilation>
<authentication mode="Forms">
<forms loginUrl="~/Account/LogOn" timeout="2880" />
</authentication>
<pages>
<namespaces>
<add namespace="System.Web.Helpers" />
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
<add namespace="System.Web.WebPages"/>
<add namespace="ConsumerMVC3.App_Code"/>
</namespaces>
</pages>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules runAllManagedModulesForAllRequests="true"/>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="2147483648" />
</requestFiltering>
</security>
</system.webServer>
誰か私にいくつかの提案をしてもらえますか?
ありがとう、コリン