Daily Archives

Articles indexed Saturday April 3 2010

Page 20/78 | < Previous Page | 16 17 18 19 20 21 22 23 24 25 26 27  | Next Page >

  • Is there anyway to make a Rails / Rack application tell the web server to drop the connection

    - by dasil003
    There are many security reasons why one would want to drop an HTTP connection with no response (eg. OWASP's SSL best practices). When these can be detected at the server level then it's no big deal. However, what if you can only detect this condition at the application level? Does Rails, or more generally Rack, have any standard way of telling the server to drop the connection without a response? If not, are there some standard headers to pass in that will accomplish that in common web servers (I'm thinking Nginx or Apache)? Even if there is not a standard header is there a reasonable way to configure that behavior? Is this a fool's errand?

    Read the article

  • DisplayFor ignores metadata

    - by Juvaly
    For my Contact class, the property EmailAddress is marked with the [DataType(DataType.EmailAddress)] attribute. In my view, using Html.Display("EmailAddress") and Html.DisplayFor(c => c.EmailAddress) yields different results. The former outputs a mailto: link, which is the expected behavior, while the latter simply outputs the email address as plain text. My question is why the different behavior, I expected these two methods to have the same output.

    Read the article

  • C++ superclass constructor calling rules

    - by levik
    What are the C++ rules for calling the superclass constructor from a subclass one?? For example I know in Java, you must do it as the first line of the subclass constructor (and if you don't an implicit call to a no-arg super constructor is assumed - giving you a compile error if that's missing).

    Read the article

  • CSRF Protection in AJAX Requests using MVC2

    - by mnemosyn
    The page I'm building depends heavily on AJAX. Basically, there is just one "page" and every data transfer is handled via AJAX. Since overoptimistic caching on the browser side leads to strange problems (data not reloaded), I have to perform all requests (also reads) using POST - that forces a reload. Now I want to prevent the page against CSRF. With form submission, using Html.AntiForgeryToken() works neatly, but in AJAX-request, I guess I will have to append the token manually? Is there anything out-of-the box available? My current attempt looks like this: I'd love to reuse the existing magic. However, HtmlHelper.GetAntiForgeryTokenAndSetCookie is private and I don't want to hack around in MVC. The other option is to write an extension like public static string PlainAntiForgeryToken(this HtmlHelper helper) { // extract the actual field value from the hidden input return helper.AntiForgeryToken().DoSomeHackyStringActions(); } which is somewhat hacky and leaves the bigger problem unsolved: How to verify that token? The default verification implementation is internal and hard-coded against using form fields. I tried to write a slightly modified ValidateAntiForgeryTokenAttribute, but it uses an AntiForgeryDataSerializer which is private and I really didn't want to copy that, too. At this point it seems to be easier to come up with a homegrown solution, but that is really duplicate code. Any suggestions how to do this the smart way? Am I missing something completely obvious?

    Read the article

  • Change values in first key from 0 to count(array) - 1

    - by sologhost
    Ok, I have an array like so: $myArray[32]['value'] = 'value1'; $myArray[32]['type'] = 'type1'; $myArray[33]['value'] = 'value2'; $myArray[33]['type'] = 'type2'; $myArray[35]['value'] = 'value3'; $myArray[42]['value'] = 'value4'; $myArray[42]['type'] = 'type4'; Ok, looking for a quick way to change all numbers in the first key 32, 33, 35, and 42 into 0, 1, 2, and 3 instead. But I need to preserve the 2nd key and all of the values. The array is already ordered correctly, since I ordered it using a ksort, but now I need to reset the array from 0 - count($myArray) - 1 and keep the 2nd key intact and its value as well. Can someone please help me?

    Read the article

  • ASP.NET MVC2 - Resolve Parameter Attribute in Model Binder

    - by Nathan Taylor
    Given an action like: public ActionResult DoStuff([CustomAttribute("foo")]string value) { // ... } Is there any way to resolve the instance of value's CustomAttribute within a ModelBinder? I was looking at the MVC sources and chances are I'm just doing it wrong, but when I tried to replicate their code which retrieves the BindAttribute for a complex model, calling GetAttributes() did not return the attribute I am looking for. DefaultModelBinder GetTypeDescriptor(controllerContext, bindingContext).GetAttributes();

    Read the article

  • Google Maps integration with JSON - CircularReferenceError

    - by JZ
    I'm working on Rails 3.0.0.beta2, following Advanced Rails Recipes "Recipe #32, Mark locations on a Google Map" and I hit a road block. The following code is returning a "ActiveSupport::JSON::Encoding::CircularReferenceError" "object references itself" at line 3. This code represents the /layouts/maps.html.erb file <% if @maps -%> <script type="text/javascript"> var maps = <%= @maps.to_json %>; </script> <% end -%> This is my first attempt at rendering JSON, and I don't know how to debug this problem. Do you have experience with this? What could cause this problem? Thank you in advance!

    Read the article

  • MVC2 Checkbox problem...

    - by BitFiddler
    When I used the html Helper Checkbox, it produces 2 form elements. I understand why this is, and I have no problem with it except: The un-checking of the checkbox does not seem to be in sync with the 'hidden' value. What I mean is that when I have a bunch of checkboxes being generated in a loop: <%=Html.CheckBox("model.MarketCategories[" & i & "].Value", category.Value)%> and the user deselects and checkbox and the category.Value is FALSE, the code being generated is: <input checked="checked" id="model_MarketCategories_0__Value" name="model.MarketCategories[0].Value" type="checkbox" value="true" /> <input name="model.MarketCategories[0].Value" type="hidden" value="false" /> This is wrong since the Value is False the checkbox should NOT be checked. Any ideas why this is happening?

    Read the article

  • When to drop an IT job

    - by Nippysaurus
    In my career I have had two programming jobs. Both these jobs were in a field that I am most familiar with (C# / MSSQL) but I have quit both jobs for the same reason: unmanageable code and bad (loose) company structure. There was something in common with both these jobs: small companies (in one I was the only developer). Currently I am in the following position: being given written instructions which are almost impossible to follow (somewhat of a fools errand). we are given short time constraints, but seldom asked how long work will take, and when we do it is always too long and needs to be shorter (and when it ends up taking longer than they need it to take, it's always our fault). there is no time for proper documenting, but we get blamed for not documenting (see previous point). Management is constantly screwing me around, saying I'm underperforming on a given task (which is not true, and switching me to a task which is much more confusing). So I must ask my fellow developers: how bad does a job need to be before you would consider jumping ship? And what to look out for when considering taking a job. In future I will be asking about documented procedures, release control, bug management and adoption of new technologies. EDIT: Let me add some more fuel to the fire ... I have been in my current job for just over a year, and the work I am doing almost never uses any of the knowledge I have gained from the other work I have been doing here. Everything is a giant learning curve. Because of this about 30% of my time is learning what is going on with this new product (who's owner / original developer has left the company), 30% trying to find the relevant documentation that helps the whole thing make sense, 30% actually finding where to make the change, 10% actually making the change.

    Read the article

  • MVC2 Strong typing breaking changes...

    - by BitFiddler
    I had the code working for: http://stackoverflow.com/questions/1930229/post-idictionary-back-to-mvc-model I recently migrated to MVC2 and now all my collections/dictionaries are coming back null. I can't seem to find any information about what has changed in the new release to cause this. Anyone know of something that might help?

    Read the article

  • How can we set authorization for a whole area in ASP.NET MVC?

    - by CodingTales
    I've an Admin area and I want only Admins to enter the area. I considered adding the Authorized attribute to every controller in the Admin area. Isn't there an elegant solution or is this feature not there in the framework itself? EDIT: I'm sorry, I should to have mentioned this before. I'm using a custom AuthorizedAttribute derived from AuthorizeAttribute.

    Read the article

  • mysqli real_escape_string problem

    - by tridat
    When im inserting to the database on my dev server the text goes in fine, for example "that's" is "that's" in the db. when uploading the exact same code to production server (hosted on a reseller account at bluehost) "that's" becomes "that\'s", im not double escaping, its exactly the same code, what could be the issue here?

    Read the article

  • Why do i need PUT or DELETE Http Verbs ?

    - by Barbaros Alp
    After the release of MVC 2, i have started to check and play with the new features. But i couldnt understand that why do i need to use PUT or DELETE verbs ? I have searched about it and read some articles but i couldnt get it. What is the main purpose of DELETE and PUT (and do they have any advantages rather than using a GET or POST method) even though i can handle all of the requests with GET and POST...

    Read the article

  • Where is the handy designer for setting Permissions and schema diagram designer in a SQL2005 Databas

    - by BlackMael
    I have just installed the GDR RTM version of Visual Studio Team System Database Edition GDR RTM. It all seems to work wonderfully, but I seem to have to edit XML (Database.sqlpermissions) for specify SQL Permissions. Am I missing something? For that matter where is the schema diagram tool? I understand GDR exposes alot for extending the Database Edition components, so am I supposed to wait for third party extensions to provide the diagram tool and permissions designer?

    Read the article

  • IsValidLocale returns FALSE - how to overcome this?

    - by sharptooth
    When run on a Spanish version of Windows XP my program invokes LANGID langId = (LANGID) MAKELANGID( LANG_ENGLISH, SUBLANG_DEFAULT ); LCID locale = MAKELCID( language, SORT_DEFAULT ); BOOL isValid = IsValidLocale( locale, LCID_INSTALLED ); IsValideLocale() return FALSE when asked about English locale. Obviously something must be tuned in Windows to change this behaviour. What exactly should I do? I understand that it's not completely a programming question but rather a deployment question. Still I think it will be better off here than anywhere else.

    Read the article

  • Lists NotifyPropertyChanging

    - by Carlo
    Well BindingList and ObservableCollection work great to keep data updated and to notify when one of it's objects has changed. However, when notifying a property is about to change, I think these options are not very good. What I have to do right now to solve this (and I warn this is not elegant AT ALL), is to implement INotifyPropertyChanging on the list's type object and then tie that to the object that holds the list PropertyChanging event, or something like the following: // this object will be the type of the BindingList public class SomeObject : INotifyPropertyChanging, INotifyPropertyChanged { private int _intProperty = 0; private string _strProperty = String.Empty; public int IntProperty { get { return this._intProperty; } set { if (this._intProperty != value) { NotifyPropertyChanging("IntProperty"); this._intProperty = value; NotifyPropertyChanged("IntProperty"); } } } public string StrProperty { get { return this._strProperty; } set { if (this._strProperty != value) { NotifyPropertyChanging("StrProperty"); this._strProperty = value; NotifyPropertyChanged("StrProperty"); } } } #region INotifyPropertyChanging Members public event PropertyChangingEventHandler PropertyChanging; #endregion #region INotifyPropertyChanged Members public event PropertyChangedEventHandler PropertyChanged; #endregion public void NotifyPropertyChanging(string propertyName) { if (this.PropertyChanging != null) PropertyChanging(this, new PropertyChangingEventArgs(propertyName)); } public void NotifyPropertyChanged(string propertyName) { if (this.PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); } } public class ObjectThatHoldsTheList : INotifyPropertyChanging, INotifyPropertyChanged { public BindingList<SomeObject> BindingList { get; set; } public ObjectThatHoldsTheList() { this.BindingList = new BindingList<SomeObject>(); } // this helps notifie Changing and Changed on Add private void AddItem(SomeObject someObject) { // this will tie the PropertyChanging and PropertyChanged events of SomeObject to this object // so it gets notifies because the BindingList does not notify PropertyCHANGING someObject.PropertyChanging += new PropertyChangingEventHandler(someObject_PropertyChanging); someObject.PropertyChanged += new PropertyChangedEventHandler(someObject_PropertyChanged); this.NotifyPropertyChanging("BindingList"); this.BindingList.Add(someObject); this.NotifyPropertyChanged("BindingList"); } // this helps notifies Changing and Changed on Delete private void DeleteItem(SomeObject someObject) { if (this.BindingList.IndexOf(someObject) > 0) { // this unlinks the handlers so the garbage collector can clear the objects someObject.PropertyChanging -= new PropertyChangingEventHandler(someObject_PropertyChanging); someObject.PropertyChanged -= new PropertyChangedEventHandler(someObject_PropertyChanged); } this.NotifyPropertyChanging("BindingList"); this.BindingList.Remove(someObject); this.NotifyPropertyChanged("BindingList"); } // this notifies an item in the list is about to change void someObject_PropertyChanging(object sender, PropertyChangingEventArgs e) { NotifyPropertyChanging("BindingList." + e.PropertyName); } // this notifies an item in the list has changed void someObject_PropertyChanged(object sender, PropertyChangedEventArgs e) { NotifyPropertyChanged("BindingList." + e.PropertyName); } #region INotifyPropertyChanging Members public event PropertyChangingEventHandler PropertyChanging; #endregion #region INotifyPropertyChanged Members public event PropertyChangedEventHandler PropertyChanged; #endregion public void NotifyPropertyChanging(string propertyName) { if (this.PropertyChanging != null) PropertyChanging(this, new PropertyChangingEventArgs(propertyName)); } public void NotifyPropertyChanged(string propertyName) { if (this.PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); } } Sorry, I know this is a lot of code, which takes me back to my main point IT'S A LOT OF CODE to implement this. So my question is, does anyone know a better, shorter, more elegant solution? Thanks for your time and suggestions.

    Read the article

  • How make this jquery function reusable?

    - by Pandiya Chendur
    Comsider this jquery function, function showresults(jsonobj) { $.each(jsonobj, function(i, employee) { divs += '<div class="resultsdiv"><br /><span style="display: inline-block;width:150px;" class="resultName">' + employee.Emp_Name + '</span><span class="resultfields" style="padding-left:100px;">Category&nbsp;:</span>&nbsp;<span class="resultfieldvalues">' + employee.Desig_Name + '</span><br /><br /><span id="SalaryBasis" class="resultfields">Salary Basis&nbsp;:</span>&nbsp;<span class="resultfieldvalues">' + employee.SalaryBasis + '</span><span class="resultfields" style="padding-left:25px;">Salary&nbsp;:</span>&nbsp;<span class="resultfieldvalues">' + employee.FixedSalary + '</span><span style="font-size:110%;font-weight:bolder;padding-left:25px;">Address&nbsp;:</span>&nbsp;<span class="resultfieldvalues">' + employee.Address + '</span></div>'; }); } Here i am iterating my json data and drawing div elements.... As you see these div elements are hardcoded how to pass these html div elements dynamically by a variable... var divs=<div></div> function showresults(jsonobj,divs) { $.each(jsonobj, function(i, employee) { divs += divs Is this correct way of doing but there will be an error employee object wont be there know when my divs variable declared outside the function... Any suggestion...

    Read the article

  • Having problems building Cairo on x64 CentOS

    - by Vnuk
    I've done this many times on 32 bit CentOS and everything went ok without a hitch. But now, on x64 CentOS, I can't get cairo to find pixman. Pixman 0.18.0 is installed in /usr/local/lib (which I believe is the usual location). Configure for Cairo 1.8.10 can't find it: checking for cairo's image surface backend feature... checking for pixman... no no checking whether cairo's image surface backend feature could be enabled... no (requires pixman-1 >= 0.12.0 http://cairographics.org/releases/) configure: error: mandatory image surface backend feature could not be enabled I've tried setting environment variable pixman_LIBS=/usr/local/lib but wihtout any luck. Any idea what is going wrong? Is it possible for me to see where is cairo's configure looking for pixman? Search paths or something like that?

    Read the article

  • How to set order of appearance for fields when using Html.EditorFor in MVC 2?

    - by Anrie
    I have the following classes in my Model: public abstract class Entity : IEntity { [ScaffoldColumn(false)] public int Id { get; set; } [Required,StringLength(500)] public string Name { get; set; } } and public class Model : SortableEntity { [Required] public ModelType Type { get; set; } [ListRequired] public List<Producer> Producers { get; set; } public List<PrintArea> PrintAreas { get; set; } public List<Color> Colors { get; set; } } To display the "Model" class in the view I simply call Html.EditorFor(model=model), but the "Name" property of the base class is rendered last, which is not the desired behaviour. Is it possible to influenece on the order of displayed fields somehow?

    Read the article

  • Software to draw 3D geometry

    - by ilovekonoka
    Does anyone know any software that can draw 3D geometry like figures usually seen in computer graphics papers and articles(example: http://www.iquilezles.org/www/articles/sphereao/sphereao.htm)? I know it can be done in Inskcape or Illustrator but I'm not sure they're the only choices.

    Read the article

< Previous Page | 16 17 18 19 20 21 22 23 24 25 26 27  | Next Page >