ASPX 页面响应.重定向到 MVC 视图 [英] ASPX Page Response.Redirect to MVC View

查看:21
本文介绍了ASPX 页面响应.重定向到 MVC 视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在从 MVC 返回视图的 aspx 中进行 Response.Redirect?

Is it possible to Response.Redirect in aspx that returns a view from MVC?

我有一个 login.aspx 页面,我需要在成功登录后重定向到 ~/Views/Home/index.cshtml 中的视图,这可能吗?我已尝试关注,但无法解析网址.

I have an login.aspx page that i need upon successful login to redirect to a view in ~/Views/Home/index.cshtml is this possible? I've tried to following but the url couldnt be resolved.

尝试过:

  1. Response.Redirect("~/Views/Home/Index.cshtml");

Response.Redirect("Home");

控制器是HomeController",视图是Index.cshtml",任何关于如何调用控制器和视图的帮助或至少只有 url 会有所帮助.

The controller is "HomeController" and the view is "Index.cshtml" any help with how to call a controller and view or atleast just the url would help.

推荐答案

Response.Redirect("/Home/Index"); - 当然前提是你有一个 HomeController 带有 Index 操作,返回您正在查找的视图(按照惯例,它将是与操作同名的视图,除非您另行指定).

How about Response.Redirect("/Home/Index"); - that is of course presuming that you have a HomeController with an Index action that returns the view you're looking for (by convention it's going to be a view having the same name as the action, unless you specify otherwise).

这篇关于ASPX 页面响应.重定向到 MVC 视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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