1

我目前有一个上传表单,看起来像

<form action="/Upload/Registration?measurementId=139" enctype="multipart/form-data" method="post">
    <fieldset>
        <legend>Registrationfiles</legend>
        <input type="hidden" name="MeasurementId" value="139"/>
            <div class="editor-field">
                <input id="RadioSelection" name="RadioSelection" type="radio" value="0" />
                <label>or</label>
                <input type="hidden" name="RecordId[0]" value="375" />
                <input type="file" name="RegistrationFile[0]" />
            </div>
        <p class="submit">
            <input type="submit" value="Save" />
        </p>
    </fieldset>
</form>

我有两种方法UploadController

[Authorize]
public ActionResult Registration(int measurementId)
{
    [...]
    return View(registrationViewModel);
}

[HttpPost]
[Authorize]
public ActionResult Registration(RegistrationViewModel data, ICollection<int> RecordId, ICollection<HttpPostedFileBase> RegistrationFile)
{
    [...]
}

当我访问http://mySite.com/Upload/Registration?measurementId=139时,我得到了表单(如预期的那样),但是当我提交它时,我得到了Error 500 - (Internal Server Error).

这个错误的原因是什么?

我有很多断点,但没有一个被击中。它只说明“错误 500”。

这是响应标头:

HTTP/1.1 500 Internal Server Error
Cache-Control: private, s-maxage=0
Server: Microsoft-IIS/7.5
X-AspNetMvc-Version: 3.0
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Sun, 17 Feb 2013 18:50:13 GMT
Content-Length: 0

编辑:当我删除第二种方法时,我没有收到错误 500。而且我从来没有收到YSOD

4

1 回答 1

0

在您的 web.config 中,将 customErrors 设置为“On”并重定向到 Error.cshmtl。您应该这样做只是为了修复 500 错误,然后再将其放回“关闭”。

For further instructions see Can't get defaultRedirect to work or https://stackoverflow.com/a/6211961/1176596 .

One possible problem might be that one of your used Models in a View lacks a default constructor. If so, you will get a MissingMethodException in your Error view.

于 2013-02-22T12:56:32.583 回答