controller

C#. What “The type T must be a reference type in order to use it as parameter.” means?

泪湿孤枕 提交于 2019-12-05 01:14:31
I'm trying to create a generic controller on my MVC C# Entity Framework Application. public class GenericRecordController<T> : Controller { private DbSet<T> Table; // ... public action(){ // ... db.Entry(T_Instance).State = System.Data.Entity.EntityState.Modified; } } However the DbSet< T > and T_Instance line has a compiler error. The type T must be a reference type in order to use it as parameter. When I constraint it for a class Controller where T : class it was solved. What does the error above means? I'm not asking for a solution. I would like to understand why this error occurs and why

How can I use mock models in AuthLogic controller specs?

家住魔仙堡 提交于 2019-12-05 00:54:36
问题 I am trying to write specs for a controller without using fixtures (instead employing mock models). This controller requires a user to be logged in, for which I'm employing AuthLogic, following the author's recommendations. describe UsersController do def mock_user(stubs={}) @mock_user ||= mock_model(User, stubs) end context 'when logged in' do before { activate_authlogic } it "exposes the logged-in user as @user in response to GET (show)" do UserSession.create(mock_user) ... end ... end ...

ZF2 Use Redirect in outside of controller

一曲冷凌霜 提交于 2019-12-05 00:51:08
问题 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- 回答1

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

一曲冷凌霜 提交于 2019-12-05 00:20:30
问题 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

Controller (Spring Managed Bean) Scope Question: Singleton, Request or Session?

感情迁移 提交于 2019-12-05 00:11:43
问题 The question is a bit long since it's conceptual. I hope it's not a bad read :) I'm working in a performance critical Spring MVC/Tiles web-app (10,000 users typical load). We load an update employee screen, where we load an employee details screen (bound to an employee business object) for updates via a MultiActionController. There are multiple tabs on this screen, but only tab1 has the updatabale data. Rest of the tabs are read-only stuff, for reference basically. Needless to say, we've

Simulink: PID Controller - difference between back-calculation and clamping for anti-windup?

点点圈 提交于 2019-12-05 00:04:23
问题 I need to implement an anti-windup (output limitation) for my PID controller. Simulink is offering two options: back calculation and clamping (documentation) which seem to deliver equal results. I know what back calculation is doing mathematically. It requires to define the back-calculation gain Kb . This gain is dependent on how long my controller is saturated, therefore it is actually a dynamic value (because I may have a high variation of saturation times). Do you see a way to control this

AngularJS: How to pass data from view to controller in angularjs

北城余情 提交于 2019-12-04 23:40:10
问题 I'm developing an application which adds/edits/removes contacts. Here is how my adding contact view template looks like: <input placeholder="name" ng-model="contact.name" type="text"> <input placeholder="number" ng-model="contact.number" type="text"> <a href="#/"><button>Add</button></a> And here is my controllers file, the controller used for adding is the last one: var myApp = angular.module('myApp', ['ngRoute']).config(function ($routeProvider) { $routeProvider.when('/contact/:index', {

Return Image from Controller symfony2

陌路散爱 提交于 2019-12-04 23:30:37
I would like to know how can i return an image from the controller without any template. I would like to use it for pixel tracking in a newsletter. I start with this code $image = "1px.png"; $file = readfile("/path/to/my/image/1px.png"); $headers = array( 'Content-Type' => 'image/png', 'Content-Disposition' => 'inline; filename="'.$file.'"'); return new Response($image, 200, $headers); But on the navigator i have a broken link (file not found...) Nicolai Fröhlich Right now you return the filename as response body and write the file-content to the filename property of Content-Disposition.

Laravel 5 - how to run a Controller method from an Artisan Command?

倖福魔咒の 提交于 2019-12-04 22:48:50
问题 I need some code from my Controller to run every ten minutes. Easy enough with Scheduler and Commands . But. I've created a Command , registered it with Laravel Scheduler (in Kernel.php ) and now I am unable to instantiate the Controller . I know it's a wrong way to approach this problem, but I just needed a quick test. Is there a way, mind you a hacky way, to accomplish this? Thank you. Update #1: The Command : <?php namespace App\Console\Commands; use Illuminate\Console\Command; use App

MVC Model is null in OnExecuted action filter … or a more elegant way to set the model?

筅森魡賤 提交于 2019-12-04 21:15:43
问题 I have an ActionFilter with an override on the OnActionExecuted method. The filterContext.Controller.ViewData.Model is always null on a POST operation. I did find the following article that seems to be saying that it should not be null but this must have been an earlier version of MVC. This is MVC3. What should I be getting? Model availability inside ActionFilter UPDATE: I've figured out the answer to the original question. I had a custom ActionResult that outputs JSON with a custom date