html打开找不到控制器,c# - 在Razor视图中使用@Html.Action成功进入新的控制器,但执行控制器后没有进入新控制器的视图。 - SO中文参考 - www.soinside.com...

我使用的是MVC .net框架,对asp.net mvc很陌生,提前道歉。我的疑问是,我能够在我的第一个控制器和视图中成功加载一个csv文件。在我的第一个视图中,我然后进入我的 NextController 然后进行主要处理。直到这里,一切都很好。从这里开始,我现在要把这个移到我下一个控制器的视图中。FxProcess. 相反,它返回到现有视图,并抱怨新模型的命名空间问题。FxOrder. 我到底哪里出错了?这是我的控制器和视图。

HomeController.cspublic class HomeController : Controller

{

// GET: Home

public ActionResult Upload()

{

return View();

}

[HttpPost]

[ValidateAntiForgeryToken]

public ActionResult Upload(HttpPostedFileBase upload, SecTypeDetails secTypeUsed)

{

if (ModelState.IsValid)

{

if (upload != null && upload.ContentLength > 0)

{

if (upload.FileName.EndsWith(".csv"))

{

var csvParser = new TextFieldParser(upload.InputStream);

var fileName = upload.FileName;

var newview = new Trade0Tron.web.Models.SecTypeDetails { sectype = secTypeUsed.sectype, csvParser = csvParser, fileName = fileName };

return View(newview);

}

else

{

ModelState.AddModelError("File", "This file format is not supported");

return View();

}

}

else

{

ModelState.AddModelError("File", "Please Upload Your file");

}

}

return View();

}

}

上传.cshtml@model Trade0Tron.web.Models.SecTypeDetails

@using System.Data;

Upload File

@using (Html.BeginForm("Upload", "Home", null, FormMethod.Post, new { enctype = "multipart/form-data" }))

{

@Html.AntiForgeryToken()

@Html.ValidationSummary()

Select SecType to run

@Html.EnumDropDownListFor(

x => x.sectype,

new { @class = "form-control" })

if (Model != null)

{

@Html.Action("FxProcess", "Next", Model)

}

}

NextController.cspublic class NextController : Controller

{

public ActionResult FxProcess(SecTypeDetails secTypeUsed)

{

var wk = new Work();

var fxOrder = wk.FxFileProcessing("", secTypeUsed.fileName, "csv", secTypeUsed.sectype.ToString(), false, secTypeUsed.csvParser);

return View("FxProcess", fxOrder);

}

}

和对应的cshtml如下@model Models.Fx.FxOrder

@using System.Data;

Upload File

@using (Html.BeginForm("FxProcess", "FxTrade"))

{

@Html.AntiForgeryToken()

@Html.ValidationSummary()

if (Model != null)

{

@Html.Action("GetResult", "FxResult", Model)

我理想中的结果是NextController 动作进入其对应的视图,然后进入结果控制器。其中又有一个结果视图来显示结果。另外注意NextController有一个新的模型Models.Fx.FxOrder。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值