从MVC重定向到Web表单(.aspx) [英] Redirect from MVC to Web form(.aspx)

查看:83
本文介绍了从MVC重定向到Web表单(.aspx)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用相同的解决方案从MVC应用程序重定向到ASP.Net Web表单应用程序。



我尝试过这样的方法

How to redirect from MVC application to ASP.Net Web-form application with in same solution.

I have tried some method like this

[HttpPost]
        public ActionResult Home(LoginUser lu)
        {
            return Redirect("http://localhost:51410/SessionWebFrom/Login.aspx");
        }







但有异常:404错误



'/'应用程序中的服务器错误。



无法找到资源。



描述: HTTP 404.您要查找的资源(或其中一个依赖项)可能已被删除,名称已更改或暂时不可用。请查看以下网址,确保拼写正确。



请求的网址: /SessionWebFrom/Login.aspx




But got exception: 404 Error

Server Error in '/' Application.

The resource cannot be found.

Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.

Requested URL: /SessionWebFrom/Login.aspx

推荐答案

您可以从MVC操作重定向到任何地方,您必须使用RedirectResult。 RedirectResult是一种ActionResult。

You can redirect to anywhere from MVC action and you have to use RedirectResult for that. RedirectResult is a type of ActionResult.

对于ex。

public RedirectResult RedirectToAspx()
{
  return Redirect("/pages/index.aspx");
}

希望有所帮助:)


这篇关于从MVC重定向到Web表单(.aspx)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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