controller

Creating ViewResults outside of Controllers in ASP.NET MVC

Several of my controller actions have a standard set of failure-handling behavior. In general, I want to: Load an object based on the Route Data (IDs and the like) If the Route Data does not point to a valid object (ex: through URL hacking) then inform the user of the problem and return an HTTP 404 Not Found Validate that the current...

ZF create a new controller

Hello, I made my first project with ZF, used the Zend_Tool component. For the index controller a created some actions, and they work well. But my question is, when do you create a new controller? thanks! ...

Zend: Get the current url for use in Controller

I have this controller which will simply change the language in a session so I can set it in the bootstrap. Except I want to change '$this->_redirect ( 'library/recipes/list' );' to be the URL of the page they are on. Ive tried a few functions and they dont seem to work. Im a newbie Zend user, thanks! class Library_LanguageswitchCon...

BestPractices: Is it acceptable to use more than one repository in a MVC-Controller?

I have a many-to-many assocition between an Employee and a Team. Foreach entity I have a repository. Now I use ASP.NET MVC and I created a EmployeeController. I also created a View to edit an Employee. For this view I need a DropDownList with all Teams. The problem is that my EmployeeController only has got EmployeeRepository. So how ca...

asp.net mvc Overriding CreateController of DefaultContollerFactory ?

public override IController CreateController(System.Web.Routing.RequestContext requestContext, string controllerName) Is it normal that the controllerName passed into this function is sometimes "content"? how can i avoid that? public override IController CreateController(System.Web.Routing.RequestContext requestContext, string co...

getJSON not working if the mvc model view controller has a parameter

I'm having an issue with a callback. I'm not even getting an error in Firebug. If I alert before and after the getjson call both alerts show but the getjson call doesn't fire. public ActionResult TestPage() { return View(); } public ActionResult LoadMapLonLats(int mapId) { //some code return Json...

asp.net mvc is it proper to create an instance of a controller in another controller's constructor?

Hi, i have several controllers which will all be using common functionality. So i have separated that functionality into a separate controller. the shared controller needs a parameter specific to which controller it is being used from, and needs to return views based on id ints passed to it. So, one idea is to create an instance of S...

How to output something before i return the view?

Hi. I'm working with the spring mvc, and have the following problem: This is for a specific view: The controller instansiates an object (from now on, called listenObject) which runs a thread that listens for a response from a server. Right now, the controller returns a json object (to the view) if the listenObject have received a resp...

ASP.NET MVC: Is it possible to get the controllername inside of a view?

I have this helper in my view: <%= Html.StandardOverlayCreateButton<EmployeeController>()%> It creates the following HTML: <a rel="#overlay" href="/Employee/Create"> <button type="button"> Create</button> </a> I do not like this anyway. Any suggestions :) ? I also askmyself when to create html helper extension and when just wri...

Distinguishing controller actions using authorization filters

I would like to have 4 actions with the same name (controller methods may have a different name, but their ActionName() attribute is the same for all 4 of them: [ActionName("Same-name")] public ActionResult AnonAction() { ... } [HttpPost] [ActionName("Same-name")] public ActionResult AnonAction(ModelData data) { ... } [Authorize] [Act...

MS Unit Tests accessing private methods and base class members

Hi Today I ran into a problem where I cannot call the ControllerContext in my Controller, within the MS Unit Test method when accessing via a private method. For example //This is my controller and private GetUsers() method public class SampleController : Controller { private IEnumerable<Users> GetUsers() { ...

How do you prefer to structure your controller(s) in CodeIgniter?

Hi, I was wondering how you find it most easy to setup your controllers. Do you use one controller pr. sub-section of your site (ie. “Friends”, “Inbox”, “My account” etc.), or do you just use one controller that keeps all of the sub-sections? ...

Passing variables to Controller via RESTful routing in Rails

The following question is related to passing a variable from routes to the controller. I have a Ruby on Rails (v 2.3.3) app with one model, which is delivered to the user with multiple views. The current solution involves using multiple controllers which are triggered by multiple routes. For example: ActionController::Routing::Routes.dr...

Testing a scoped find in a Rails controller with RSpec

I've got a controller called SolutionsController whose index action is different depending on the value of params[:user_id]. If its nil, then it simply displays all of the solutions on my site, but if its not nil, then it displays all of the solutions for the given user id. Here it is: def index if(params[:user_id]) @solutio...

Setting delay in pushing view controller iphone

I am creating a navigation based application. I have different views which are pushed and poped from navigation controller. (pop is mainly using back button). Here is the code i am using for pushing view controller. MyViewController *dvController = [[MyViewController alloc] initWithNibName:@"MyViewController" bundle:nil]; [s...

How to sort some values from an array in a controller in Rails?

I've got a links array that I'm saving to a database. The problem is that the records aren't saved in the order of the array ie links[1] is saved before links[2] and so on... This is a example from the view file: <p> <label for="links_9_label">Label</label> <input id="links_9_name" name="links[9][name]" size="30" type="text" /> <...

Fat ASP.NET MVC Controllers

Hello, I have been reading about "Fat Controllers" but most of the articles out there focus on pulling the service/repository layer logic out of the controller. However, I have run into a different situation and am wondering if anyone has any ideas for improvement. I have a controller with too many actions and am wondering how I can ...

ASP.NET MVC controllers with identical names

Hi! Here's what I'm trying to do. I have an ASP.NET MVC web application, where I'd like to have a separate "admin" area (accessible via http://example.com/admin) and a regular area, available for all users. In both these parts of the site I have a /blogs section, but when accessing http://example.com/admin/blogs I want to be presented ...

Overloading Controller Actions

Hi Guys I was a bit surprised a few minutes ago when I tried to overload an Action in one of my Controllers I had public ActionResult Get() { return PartialView(/*return all things*/); } I added public ActionResult Get(int id) { return PartialView(/*return 1 thing*/); } .... and all of a sudden neither were working I f...

Another Navigation Controller and View Controller Question

I have a NavigationController based app. TableViewController loads Array. User clicks Cells and Xib(view controller) is pushed to top of stack. Question is, Can I load another Xib off the Current Xib...Thanks ...