如何用户重定向到从MVC自定义路由处理程序的另一个网址? [英] How to redirect user to another Url from MVC Custom Router Handler?

查看:155
本文介绍了如何用户重定向到从MVC自定义路由处理程序的另一个网址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我与CustomMvcRouterHandler工作,根据一些逻辑我只是想用户重定向到从CustomHandler另一个URL。

I am working with CustomMvcRouterHandler, Based on some logic I just want to redirect user to another Url from CustomHandler.

public class CustomMvcRouterHandler : IRouteHandler
{

    public IHttpHandler GetHttpHandler(RequestContext requestContext)
    {
        if (requestContext.HttpContext.Request.IsAuthenticated)
        {
            if (logic is true)
            {
                string OrginalUrl = "/Home/AboutUs";
                // redirect Url = "/Home/CompanyProfile";
                return new MvcHandler(requestContext);
            }

        }

        return new MvcHandler(requestContext);
    }
}

如何重定向用户到首页/公司简介,从CustomRouterHandler?

推荐答案

您可以使用ASP.NET底层Response对象用户重定向到另一个网址。

You can use underlying ASP.NET Response object to redirect user to another URL.

requestContext.Response.Redirect("/Home/CompanyProfile");
requestContext.Response.End();

这将发送重定向响应浏览器和结束的HTTP请求处理。

It will send redirect response to the browser and end HTTP request processing.

这篇关于如何用户重定向到从MVC自定义路由处理程序的另一个网址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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