你好我正在尝试使用RedirectToAction将新发布的值传递给url中新值id的不同视图,但是我得到了错误的Url。 就像在这里一样,你会在提交后重定向到你的Q. 我想要得到的网址是http://localhost:1914/en/evntes/index/60
MyCode(Controler = VoosUp)
$ gem uninstall libv8
$ brew install v8
$ gem install therubyracer or $ gem install therubyracer -v=0.10.1
活动/索引
public ActionResult Create()
{
var viewModel = new LectureFormViewModel
{
Genres = _context.Genres.ToList(),
};
return View("Gigform", viewModel);
}
[Authorize, HttpPost]
public ActionResult Create(LectureFormViewModel viewModel)
{
if (!ModelState.IsValid)
{
viewModel.Genres = _context.Genres.ToList();
return View("Gigform", viewModel);
}
var lectureGig = new LectureGig
{
//Prametrest
};
_context.LectureGigs.Add(lectureGig);
_context.SaveChanges();
// return this.RedirectToAction( "events", (c=>c.Index(lectureGig.Id)); //Compiler Error
return RedirectToAction("index", "Events", new { id = lectureGig.Id });//Ok Id 60
}
我正在获取的网址:http://localhost:1914/en/VoosUp/Create 并且视图是正确的