4

私は CustomMvcRouterHandler を使用しています。いくつかのロジックに基づいて、ユーザーを CustomHandler から別の Url にリダイレクトしたいだけです。

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 から "Home/CompanyProfile" にリダイレクトする方法は?

4

1 に答える 1

1

基になる ASP.NET Response オブジェクトを使用して、ユーザーを別の URL にリダイレクトできます。

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

ブラウザにリダイレクト レスポンスを送信し、HTTP リクエストの処理を終了します。

于 2013-07-18T09:49:47.180 に答える