如何与特定的视图(而不是控制器的名称)返回的ActionResult [英] How to return ActionResult with specific View (not the controller name)

查看:173
本文介绍了如何与特定的视图(而不是控制器的名称)返回的ActionResult的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在MVC Controller.This方法的方法调用的SendMail另一种方法ValidateLogin。这是验证登录的签名:

I have a method SendMail in the MVC Controller.This method calls other method ValidateLogin. This is the signature of the Validate Login:

private ActionResult ValidateLogin(Models.ResetPassword model)

当我从的SendMail致电ValidateLogin,出现此异常,因为控制器尝试搜索视图的SendMail,但我想加载ResetPassword查看:

When I call the ValidateLogin from SendMail, this exception appears because the controller try to search a view SendMail, but I want to load the ResetPassword View:

Global Error - The view 'SendMail' or its master was not found or no view engine supports the searched locations. The following locations were searched: ...

这是sendmail的的code:

This is the code of the SendMail:

public ActionResult SendMail(string login)
{
        return ValidateLogin(login);
}

我如何重写观return语句?

How Can I override the View on the return statement?

在此先感谢

推荐答案

最后,这是解决方案

return View("ResetPassword", new ResetPassword
            {
                fields= fields
            });

这篇关于如何与特定的视图(而不是控制器的名称)返回的ActionResult的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆