controller

ASP.NET MVC OutputCache doesn't work for root URI

和自甴很熟 提交于 2019-12-03 16:59:23
问题 I'm learning ASP.NET MVC and bugged by one issue. In the HomeController, the Index action has OutputCache attribute, but it seems doesn't work. [HandleError] public class HomeController : Controller { [OutputCache(Duration=5, VaryByParam="none")] public ActionResult Index() { ViewData["Title"] = "Home Page" + DateTime.Now; ViewData["Message"] = "Welcome to ASP.NET MVC! " + DateTime.Now; return View(); } } After quite a few minutes trying, I found that it is due to the way I access the action.

Pass data from an Angular modal's controller back to the main controller

一世执手 提交于 2019-12-03 16:40:40
Here is the thing. I am not able to pass data from angular modal back to the controller where i need it. the codes given below. Controller side 'use strict' var DataMod = angular.module('Data', ["angularGrid", 'ui.bootstrap.contextMenu', 'ui.bootstrap']); DataMod.controller('DataController', ['$scope', '$compile', '$uibModal', '$log','$rootScope', '$http', function ($scope, $compile, $uibModal,$log, $rootScope, $http, ngUtilityService) { //user first clicks on Add button. A modal opens up. ModalInstanceCtrl is the controller used. $scope.adduser = function () { var modalInstance = $uibModal

How can I bubble up an Ember action inside a callback function?

丶灬走出姿态 提交于 2019-12-03 16:40:11
I have an Ember application and I am using an action to apply a CSS animation. Once the animation is complete I want to bubble up the action from the controller to my route to handle further functionality. I know that if I return: true; the action will bubble up, as explained here . This is what my controller looks like: App.MyController = Ember.ObjectController.extend({ actions: { myAction: function() { $('.my-element').addClass('my-animation-class').one('webkitAnimationEnd oanimationend msAnimationEnd animationend', function(e) { console.log('working'); return true; } } } }); If I log

SceneBuilder 2: Do controller classes need to necessarily be in the same folder as the view FXML files?

青春壹個敷衍的年華 提交于 2019-12-03 16:39:30
I'm loving JavaFX and SceneBuilder, but I just can't figure out how to make SceneBuilder link my FXML views with their Java controllers when they are not in the same folder. I'd just like to have this folder structure: package |-- model |-- view | |--someElementView.fxml | \--anotherElementView.fxml \-- control |--someElementController.java \--anotherElementController.java Instead I can only make SceneBuilder recognise my controllers if I have this folder structure which I'd like to avoid: package |-- model \-- view |--someElementView.fxml |--anotherElementView.fxml |--someElementController

Can CodeIgniter Helper Functions use database functions?

前提是你 提交于 2019-12-03 16:30:27
问题 One of my CodeIgniter Controller functions needs to call a recursive function as part of its functionality. The function call chokes if I put it inside the controller class, and it can't access database functions ($this->db->get()) if I put it outside the class. Would making it a helper function fix this problem? 回答1: You can get instance: $CI =& get_instance(); After that you will be able to use $CI->db for queries.. 回答2: If you want to use $this in libraries, helpers, and access all the

ASP.NET MVC - Current Action from controller code?

血红的双手。 提交于 2019-12-03 16:23:35
问题 This is very similar to another recent question: How can I return the current action in an ASP.NET MVC view? However, I want to get the name of the current action from within controller code. So within the code of a function that's being called by an Action, I want to get a string of the name of the current Action. Is this possible? 回答1: You can access the route data from within your controller class like this: var actionName = ControllerContext.RouteData.GetRequiredString("action"); Or, if

ASP.NET Controller Base Class User.Identity.Name

╄→尐↘猪︶ㄣ 提交于 2019-12-03 16:23:04
As described in this post , I created an abstract base controller class in order to be able to pass data from a controller to master.page. In this case, I want to lookup a user in my db, querying for User.Identity.Name (only if he is logged in). However, I noticed that in this abstract base class the User property is always null . What do I have to do to get this working? Thanks a lot As Paco suggested, the viewdata isn't initialized till after you are trying to use it. Try overriding Controller.Initialize() instead: public abstract class ApplicationController : Controller { private

When do @SessionAttributes in SpringMVC get removed? (With code sample)

帅比萌擦擦* 提交于 2019-12-03 16:22:59
问题 Under what exact circumstances do @SessionAttributes get cleared? I've discovered some confusing behaviour when trying to use two models in a page. When I do a GET followed by a POST using this controller... @Controller @RequestMapping("/myPage*") @SessionAttributes(value = {"object1", "object2"}) public class MyController { @RequestMapping(method = RequestMethod.GET) public String get(Model model) { model.addAttribute("object1", new Object1()); model.addAttribute("object2", new Object2());

ZF2 Use Redirect in outside of controller

房东的猫 提交于 2019-12-03 16:17:36
I'm working on an ACL which is called in Module.php and attached to the bootstrap. Obviously the ACL restricts access to certain areas of the site, which brings the need for redirects. However, when trying to use the controller plugin for redirects it doesn't work as the plugin appears to require a controller. What's the best way to redirect outside from outside of a controller? The vanilla header() function is not suitable as I need to use defined routes. Any help would be great! Cheers- Jurian Sluiman In general, you want to short-circuit the dispatch process by returning a response. During

Spring MVC controller return HTML

元气小坏坏 提交于 2019-12-03 16:11:00
问题 I am having an issue trying when trying to return HTML to my Spring MVC controller. It looks like this: @RequestMapping(value = QUESTION_GROUP_CREATE_URL, method = RequestMethod.POST) public @ResponseBody String createQuestionGroup(@RequestBody JsonQuestionGroup questionGroup, HttpServletResponse response) { // questionGroup - this comes OK. response.setContentType("text/html"); response.setCharacterEncoding("UTF-8"); return "<div></div>"; } My Spring config: <bean id=