タイトルの種類はそれをすべて言います。これを localhost で実行すると、すべて正常に動作します。今日、いくつかのテストと BAM を実行するために展開しました! 動作していません。そして、何らかの理由でエラーを表示できるようにできないので、何が間違っているのか、実際にこれをデバッグする方法さえわかりません..
コントローラーは次のとおりです。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using DarkRobot.Models;
using System.Web.Helpers;
using System.IO;
namespace DarkRobot.Controllers
{
[Authorize]
public class UploadController : Controller
{
//
// GET: /Upload/
private DarkRobotEntities1 db = new DarkRobotEntities1();
public ActionResult Index()
{
return View();
}
[HttpPost]
public ActionResult Index(HttpPostedFileBase file, string name)
{
if (file != null && file.ContentLength > 0)
{
var fileName = Path.GetFileName(file.FileName);
var path = Path.Combine(Server.MapPath("/Images"), fileName);
file.SaveAs(path);
Image image = new Image();
image.RelativeLocation = "/Images/" + file.FileName;
image.Title = name;
db.Images.Add(image);
db.SaveChanges();
}
return RedirectToAction("Confirm");
}
public ActionResult Confirm()
{
return View();
}
}
}
そして、ここにインデックスがあります
@using (Html.BeginForm("Index", "Upload", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
<input type="file" name="file" />
<br />
<input type="text" name="name" />
<br />
<input type="submit" value="OK" />
}
これを理解しようとする必要があるものが他にある場合は、喜んで質問を更新します。私はMVCにかなり慣れていません..