简体   繁体   中英

RouteData.Values null redirect

I want to redirect to the main page if the incoming value is unknown or empty. But I did not succeed.

  if(RouteData.Values["lab"] ==null )
    {
        Response.Redirect("/Default");
    }

This is what I did to redirect to my error page, via the controller, when authenticating LDAP groups:

var routeData = new RouteData();
                    routeData.Values.Add("message", errorModel.message);
                    routeData.Values.Add("action", "Index");
                    routeData.Values.Add("controller", "ErrorPage");
                    IController ctrl = new ErrorController();
                    ctrl.Execute(new RequestContext(new HttpContextWrapper(Context), routeData));
Response.End();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM