How to wire common code from a base controller in ASP.NET MVC

前端 未结 3 1563
陌清茗
陌清茗 2021-01-05 09:23

My ASP.NET MVC application is a small part of a bigger ColdFusion app that is going to be soon replaced completely. I\'m passing some parameters from ColdFusion part through

3条回答
  •  长发绾君心
    2021-01-05 09:29

    If this is necessary on every action within a particular controller, one potential option you could probably use is to just do this in the base controller...

    public class MyBaseController: Controller
    {
        protected override void Initialize(RequestContext requestContext)
        {
            base.Initialize(requestContext);
    
            var cookie = base.Request.Cookies["coldfusioncookie"];
            //if something is wrong with cookie
                Response.Redirect("http://mycoldfusionapp");
        }
    }
    

提交回复
热议问题