controller

Asp.Net MVC - Common Data Across All Controllers

烈酒焚心 提交于 2019-12-10 17:27:56
问题 The setup: (using Asp.Net MVC 2 RC, Entity Framework, SQL Server, VS2008) My buddy and I are working on a project that will have different domains pointing at it. We want to get the domain (website) out of the Request and use that to drive data. This website data needs to be part of all the controllers. Ex. Data for domain1.website.com will be different than data for domain2.website.com, and those will be different than data for website2.com. The look of the site is the same for all these,

Retrieving a json array from a cakePHP controller

会有一股神秘感。 提交于 2019-12-10 17:24:54
问题 I want to return a JSON array from a cakePHP controller. I effectively have a jquery click event which should send either a post, ajax or get call to the controller (specified with URL) and that controller should just return the array. This makes sense to me because I will not create a view file, I literally send the response to the controller and I can set the header, echo the json array and possibly just exit. My output only says "Array" on console, and does not echo out any parameters in

Posting int arrays to MVC controller - what would be the correct method signature?

馋奶兔 提交于 2019-12-10 17:04:54
问题 Below is a screenshot of the POST request (using Firebug Net panel) I am sending to my ASP.NET MVC2 controller. This is the controller / action method that receives the POST request: public ActionResult Search(int[] skill, int[] discipline, int[] education, int[] marketsector){ ... } The parameters POSTed seem to me to be in the correct form, however the action method receives four null arguments. Could you please tell me what should the method signature look like on the server side? Or a

Set variables to 404 in zend framework 2

陌路散爱 提交于 2019-12-10 15:37:31
问题 In my controller I throw a 404 response after an If statement, something like that : if ($foo) { $this->getResponse()->setStatusCode(404); return; } Then, I would like to send some variables to my 404 page. In my mind, I want to do something like that : $this->getResponse()->setVariables(array('foo' => 'bar', 'baz' => 'bop')); $this->getResponse()->setStatusCode(404); return; It's not the good solution, so how I have to do that ? And after, how to get these variables in my 404 view ? Thank

How can I access the entire query string in an ASP.net controller action

寵の児 提交于 2019-12-10 14:59:43
问题 I know that if I have an url like XController/Action?id=1, and an action method void Action(int id) the id parameter will automatically be read from the query string. But how can I access the entire query string when I don't in advance know the name of all parameters. E.g: void Action(QueryStringCollection coll) { object id = coll["id"]; } Is it possible to do something like this? 回答1: Use Request.QueryString for this Request.QueryString.Keys gives you the name of all parameters 来源: https:/

Calling a method of another controller

柔情痞子 提交于 2019-12-10 14:45:33
问题 I have controllers named Children and Father and Mother where I need to call a method of FatherController and MotherController from ChildrenController . I need to pass a JSON data to the both controller( not at the same request ) get_details method from set_details method of ChildrenController . I am going to call any of the controllers method based on some conditions. There is no route for get_details method in both controllers. I don't need any helper methods to write. I need to call more

Symfony2 Form pre-fill fields with data

眉间皱痕 提交于 2019-12-10 14:44:16
问题 Assume for a moment that this form utilizes an imaginary Animal document object class from a ZooCollection that has only two properties ("name" and "color") in symfony2. I'm looking for a working simple stupid solution , to pre-fill the form fields with the given object auto-magically (eg. for updates ?). Acme/DemoBundle/Controller/CustomController : public function updateAnimalAction(Request $request) { ... // Create the form and handle the request $form = $this->createForm(AnimalType(),

Mininet Cannot find required executable controller

被刻印的时光 ゝ 提交于 2019-12-10 14:37:58
问题 Whenever I want to run sshd.py example in mininet or some custome code I have written myself I get *** Creating network *** Adding controller *** Adding hosts: h1 h2 h3 h4 h5 *** Adding switches: s1 *** Adding links: (h1, s1) (h2, s1) (h3, s1) (h4, s1) (h5, s1) *** Configuring hosts h1 h2 h3 h4 h5 *** Starting controller Cannot find required executable controller. Please make sure that it is installed and available in your $PATH: (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin)

Accessing ASP.NET MVC Model Data from external Javascript file

若如初见. 提交于 2019-12-10 14:16:46
问题 I'm trying to use JQuery's $.getJSON to access Model data from the Controller, and build a JSON object in the javascript to use as the user adds and removes items from a list. All JS is done in an external file. The hit to the server for the Model data is done only once after the page first loads so I can get the full list of options for the user to choose from. After that, the user can modify the list as much as he wants (and the JSON object is updated accordingly), and then save it off

Posting JSON to Controller

岁酱吖の 提交于 2019-12-10 13:57:58
问题 I've got this in my controller: [HttpPost] public void UpdateLanguagePreference(string languageTag) { if (string.IsNullOrEmpty(languageTag)) { throw new ArgumentNullException("languageTag"); } ... } And have this jQuery code POSTing to the controller: jQuery.ajax({ type: 'POST', url: '/Config/UpdateLanguagePreference', contentType: 'application/json; charset=utf-8', data: '{ "languageTag": "' + selectedLanguage + '" }' }); When I try to the code, however, I get the error: Server Error in '/'