asp.net-mvc – 重定向到mvc中的actionresult但不想通过返回视图转到页面()

我想要一个设施,如果用户登录然后转到home / index

我不想用

return view('~/views/home/index');

我想将它重定向到我的web应用程序的home controller的actionresult索引(在asp.net mvc中)

如何在没有返回视图的情况下做到这一点();我想重定向他.

public actionresult login

if(userlogin)
{
// goes to index page ? what i do here then user goes to index page of home controller
}
else
{
return view()
}

解决方法

你可以重定向:
return RedirectToAction("index");

如果操作在不同的控制器上,也指定控制器名称:

return RedirectToAction("index","home");

相关文章

### 创建一个gRPC服务项目(grpc服务端)和一个 webapi项目(...
一、SiganlR 使用的协议类型 1.websocket即时通讯协议 2.Ser...
.Net 6 WebApi 项目 在Linux系统上 打包成Docker镜像,发布为...
一、 PD简介PowerDesigner 是一个集所有现代建模技术于一身的...
一、存储过程 存储过程就像数据库中运行的方法(函数) 优点:...
一、Ueditor的下载 1、百度编辑器下载地址:http://ueditor....