コード例 #1
0
ファイル: Global.asax.cs プロジェクト: pruiz/AspMvc2
        protected void Application_Start()
        {
            // We use this hook to inject our ResourceControllerActionInvoker which can smartly map HTTP verbs to Actions
            ResourceControllerFactory factory = new ResourceControllerFactory();
            ControllerBuilder.Current.SetControllerFactory(factory);

            // We use this hook to inject the ResourceModelBinder behavior which can de-serialize from xml/json formats 
            ModelBinders.Binders.DefaultBinder = new ResourceModelBinder();

            AtomFormatHandler atom = new AtomFormatHandler();
            FormatManager.Current.RequestFormatHandlers.Add(atom);
            FormatManager.Current.ResponseFormatHandlers.Add(atom);
            JavaScriptSerializerFormatHandler jsonHandler = new JavaScriptSerializerFormatHandler();
            FormatManager.Current.RequestFormatHandlers.Add(jsonHandler);
            FormatManager.Current.ResponseFormatHandlers.Add(jsonHandler);

            FormatManager.Current.FormatHelper = new ChromeAwareFormatHelper();
            
            RegisterRoutes(RouteTable.Routes);
        }
コード例 #2
0
ファイル: Global.asax.cs プロジェクト: pruiz/AspMvc2
 public MyFormatManager()
 {
     XmlFormatHandler xmlHandler = new XmlFormatHandler();
     this.RequestFormatHandlers.Add(xmlHandler);
     this.ResponseFormatHandlers.Add(xmlHandler);
     JsonFormatHandler jsonHandler = new JsonFormatHandler();
     this.RequestFormatHandlers.Add(jsonHandler);
     this.ResponseFormatHandlers.Add(jsonHandler);
     AtomFormatHandler atom = new AtomFormatHandler();
     this.RequestFormatHandlers.Add(atom);
     this.ResponseFormatHandlers.Add(atom);
     JavaScriptSerializerFormatHandler json2Handler = new JavaScriptSerializerFormatHandler();
     this.RequestFormatHandlers.Add(json2Handler);
     this.ResponseFormatHandlers.Add(json2Handler);
 }