Search Results

Search found 1101 results on 45 pages for 'handlers'.

Page 12/45 | < Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >

  • jQuery and ASP.NET drop down problem

    - by Sayem Ahmed
    I have a drop down in an ASP.NET page. Whenever the value of the drop down changes an ASP.NET AJAX request is made to the server. I also attached a jQuery "change" event handler to that list to execute some code when the value is changed. So, probably two different event handlers are being attached to the same drop down, and it's causing some problems, i.e., sometimes wrong drop down values are sent to the server. I don't know why is this happening but I think attaching two different event handlers to a same drop down may be the reason. Can anyone tell me what is the problem here? If what I guessed is true, then is there any other way to execute some custom javascript code before asp.net AJAX request is sent ?

    Read the article

  • Unable to control requests for static files on Google App Engine

    - by dan
    My simple GAE app is not redirecting to the /static directory for requests when url is multiple levels. Dir structure: /app/static/css/main.css App: I have two handlers one for /app and one for /app/new app.yaml: handlers: - url: /static static_dir: static - url: /app/static/(.*) static_dir: static\1 - url: /app/.* script: app.py login: required HTML: Description: When page is loaded from /app HTTP request for main.css is successful GET /static/css/main.css But when page is loaded from /app/new I see the following request: GET /app/static/css/main.cs That's when I tried adding the /app/static/(.*) in the app.yaml but it is not having any effect.

    Read the article

  • How do I configure the Python logging module in Django?

    - by mipadi
    I'm trying to configure logging for a Django app using the Python logging module. I have placed the following bit of configuration code in my Django project's settings.py file: import logging import logging.handlers import os date_fmt = '%m/%d/%Y %H:%M:%S' log_formatter = logging.Formatter(u'[%(asctime)s] %(levelname)-7s: %(message)s (%(filename)s:%(lineno)d)', datefmt=date_fmt) log_dir = os.path.join(PROJECT_DIR, "var", "log", "my_app") log_name = os.path.join(log_dir, "nyrb.log") bytes = 1024 * 1024 # 1 MB if not os.path.exists(log_dir): os.makedirs(log_dir) handler = logging.handlers.RotatingFileHandler(log_name, maxBytes=bytes, backupCount=7) handler.setFormatter(log_formatter) handler.setLevel(logging.DEBUG) logging.getLogger().setLevel(logging.DEBUG) logging.getLogger().addHandler(handler) logging.getLogger(__name__).info("Initialized logging subsystem") At startup, I get a couple Django-related messages, as well as the "Initialized logging subsystem", in the log files, but then all the log messages end up going to the web server logs (/var/log/apache2/error.log, since I'm using Apache), and use the standard log format (not the formatter I designated). Am I configuring logging incorrectly?

    Read the article

  • Should non-English member names be changed to English?

    - by M.A. Hanin
    Situation: Automatically generated memebers, such as MenuStrip items, have their (automatically generated) names based on the text entered when the item was created. My most common situation is creating a menu-strip and adding menu-items by entering their text (using the graphical designer). Since my GUI is in Hebrew, all these members have a name which contains a Hebrew string. Something like "(hebrew-text)ToolStripItem". When I create event handlers, the event handlers "inherit" the hebrew text: "(hebrew-text)ToolStripMenuItem_Click". This actually works well, IntelliSense has no problem with Hebrew text, and so does the compiler. The question is: should I change these names (or prevent them from being created in the first place)? What are the possible consequences of keeping those names?

    Read the article

  • What is the chance a CouchDB document update handler will get a revision conflict?

    - by jhs
    How likely is a revision conflict when using an update handler? Should I concern myself with conflict-handling code when writing a robust update function? As described in Document Update Handlers, CouchDB 0.10 and later allows on-demand server-side document modification. Update handlers can process non-JSON formats; but the other major features are these: An HTTP front-end to arbitrarily complex document modification code Similar code needn't be written for all possible clients—a DRY architecture Execution is faster and less likely to hit a revision conflict I am unclear about the third point. Executing locally, the update handler will run much faster and with lower latency. But in situations with high contention, that does not guarantee a successful update. Or does the update handler guarantee a successful update?

    Read the article

  • how get xml responce using JAX-WS SOAP handler

    - by khris
    I have implemented web service: @WebServiceClient(//parameters//) @HandlerChain(file = "handlers.xml") public class MyWebServiceImpl {...} Also I have implemented ObjectFactory with list of classes for creating my requests and responses. For Example class Test. I need to get xml of response. I try to use JAX-WS SOAP handler, so I add this @HandlerChain(file = "handlers.xml") anotation. My handlers.xml looks like: <?xml version="1.0" encoding="UTF-8"?> <handler-chains xmlns="http://java.sun.com/xml/ns/javaee"> <handler-chain> <handler> <handler-class>java.com.db.crds.ws.service.LoggingHandler</handler-class> </handler> </handler-chain> </handler-chains> My LoggingHandler class is: import java.io.PrintWriter; import java.util.Set; import javax.xml.namespace.QName; import javax.xml.soap.SOAPMessage; import javax.xml.ws.handler.MessageContext; import javax.xml.ws.handler.soap.SOAPMessageContext; public class LoggingHandler implements javax.xml.ws.handler.soap.SOAPHandler<SOAPMessageContext> { public void close(MessageContext messagecontext) { } public Set<QName> getHeaders() { return null; } public boolean handleFault(SOAPMessageContext messagecontext) { return true; } public boolean handleMessage(SOAPMessageContext smc) { Boolean outboundProperty = (Boolean) smc.get (MessageContext.MESSAGE_OUTBOUND_PROPERTY); if (outboundProperty.booleanValue()) { System.out.println("\nOutbound message:"); } else { System.out.println("\nInbound message:"); } SOAPMessage message = smc.getMessage(); try { PrintWriter writer = new PrintWriter("soap_responce" + System.currentTimeMillis(), "UTF-8"); writer.println(message); writer.close(); message.writeTo(System.out); System.out.println(""); // just to add a newline } catch (Exception e) { System.out.println("Exception in handler: " + e); } return outboundProperty; } } I have test class which creates request, here are part of code: MyWebServiceImpl impl = new MyWebServiceImpl(url, qName); ws = impl.getMyWebServicePort(); Test req = new Test(); I suppose to get xml response in file "soap_responce" + System.currentTimeMillis(). But such file isn't even created. Please suggest how to get xml response, I'm new to web services and may do something wrong. Thanks

    Read the article

  • jQuery:Problem in Chaining the events.

    - by Shyju
    I have the following javascript function which will load data from a server page to the div This is working fine with the FadeIn/FadeOut effects function ShowModels(manuId) { var div = $("#rightcol"); div.fadeOut('slow',function() { div.load("../Lib/handlers/ModelLookup.aspx?mode=bymanu&mid="+manuId, { symbol: $("#txtSymbol" ).val() }, function() { $(this).fadeIn(); }); }); } Now i want to Show a Loading Message till the div loads the contents from the server page I tried this.But its not working.Can any one help me to debug this ? Thanks in advance function ShowModels(manuId) { var div = $("#rightcol"); var strLoadingMsg="<img src='loading.gif'/><h3>Loading...</h3>"; div.fadeOut('slow',function() { div.load(strLoadingMsg,function(){ div.load("../Lib/handlers/ModelLookup.aspx?mode=bymanu&mid="+manuId, { symbol: $("#txtSymbol" ).val() }, function() { $(this).fadeIn(); }); }); }); } My ultimate requirement is to FadeOut the current content.Show the Loading message.Show the Data coming from server with a FadeIn effect

    Read the article

  • Quality Design for Asynchronous WCF Services Calls in a Middle-Tier and Returning Data to UI Tier

    - by Perplexed
    I have a WPF application with a group of asynchronous WCF service calls all mashed into the code behind, complete with event handlers and everything, that I have to refactor to productionize and maintain. I want to separate concerns here for maintainability and all the other good reasons to do this, but I'm not sure exactly how to achieve this. Anybody have any good ideas on how to do this, or at least some links to put me in the right direction? My thinking: Create an "infrastructure" layer and reference the services there. Move the asynchronous event handlers into this layer. When an update is called, I will bubble up my own event with my own derivation of the EventArgs class that contains the data the UI will need. I'll have a fairly coupled hooking of the UI to the infrastructure layer as it will consume events I fire off upon completion of an asynchronous data call.

    Read the article

  • jQuery .toggle() called by window.setInterval() not functioning

    - by Paul Daly
    I am trying to alternate between two logos every 5 seconds using the following code: window.setInterval( function () { //breakpoint 1 $("#logo").toggle( function() { //breakpoint 2 $(this).attr('src', '/Images/logo1.png'); }, function() { //breakpoint 3 $(this).attr('src', '/Images/logo2.png'); } ); }, 5000 ); I can get a simple toggle to work, but when I introduce the toggle within window.setInterval(), the toggle's two handlers won't fire. I set breakpoints on the lines directly beneath the comments in the code above. Breakpoint 1 hits every 5 seconds. However, Breakpoint 2 and 3 never hit. Why are neither of the toggle function's handlers firing?

    Read the article

  • How to raise CComponent event in Yii

    - by srigi
    Let's assume I have Component (say Graph like Yahoo Finance) rendered on the page. Component view template contains bunch of a_hrefs which I wanto to switch period in graph. I created Event and Event handler in Component. I have two questions: How to raise event on Graph Component via those a_hrefs (should they be part of Graph?)? How to redraw Graph without loosing curent page context (section, filter - specified as $_GET values)? My Graph Component look like this: Yii::import('zii.widgets.CPortlet'); class Graph extends CPortlet { private $_period; /* ********************** * * COMPONENT PROPERTIES * * ********************** */ public function getPeriod() { return $this-_period; } public function setPeriod($period) { $this-_period = $period; } /* ********************** * * GENERIC * * ********************** */ public function init() { parent::init(); // assign event handlers $this-onPeriodChange = array($this, 'handlePeriodChange'); } protected function renderContent() { $this-render('graph'); } /* ********************** * * EVENTS * * ********************** */ public function onPeriodChange($event) { $this-raiseEvent('onPeriodChange', $event); } /* ********************** * * EVENT HANDLERS * * ********************** */ public function handlePeriodChange($event) { // CODE } }

    Read the article

  • GAE datastore - count records between one minute ago and two minutes ago?

    - by Arthur Wulf White
    I am using GAE datastore with python and I want to count and display the number of records between two recent dates. for examples, how many records exist with a time signature between two minutes ago and three minutes ago in the datastore. Thank you. #!/usr/bin/env python import wsgiref.handlers from google.appengine.ext import db from google.appengine.ext import webapp from google.appengine.ext.webapp import template from datetime import datetime class Voice(db.Model): when = db.DateTimeProperty(auto_now_add=True) class MyHandler(webapp.RequestHandler): def get(self): voices = db.GqlQuery( 'SELECT * FROM Voice ' 'ORDER BY when DESC') values = { 'voices': voices } self.response.out.write(template.render('main.html', values)) def post(self): voice = Voice() voice.put() self.redirect('/') self.response.out.write('posted!') def main(): app = webapp.WSGIApplication([ (r'.*', MyHandler)], debug=True) wsgiref.handlers.CGIHandler().run(app) if __name__ == "__main__": main()

    Read the article

  • How do I attach an event handler to the document or window in GWT?

    - by Raph Levien
    In a GWT app centered around a canvas, I'm having trouble keeping focus directed in the right place - particularly for keyboard shortcuts. For now, I've wrapped the canvas in a FocusPanel, but that causes the canvas to not respond to the RequiresResize protocol, because FocusPanel does not plumb that. A second (related, I think) problem is that the FocusPanel is not getting Ctrl-A keypress events at all (tested on Mac Chrome). I can get Ctrl-Z and other keys (such as arrows) just fine. In a pure JavaScript world, I think the best answer to this would be to attach mouse and key handlers to the document or window object (I'm not positive which is better). However, I don't see an obvious way to do this in GWT - in particular, the Document and Window classes lack methods for attaching these kind of event handlers? Anyone know how to do it, or, perhaps, to solve the more general problem of keeping focus on an appropriate widget able to handle keyboard shortcuts?

    Read the article

  • xmlserializer throwing InvalidOperationException

    - by AndyC
    I have an XmlSerializer object, and I have added 2 event handlers to the UnknownElement and UnknownAttribute events, as below: XmlSerializer xs = new XmlSerialiser(typeof(MyClass)); xs.UnknownAttribute += new XmlAttributeEventHandler(xs_UnknownAttribute); xs.UnknownElement += new XmlElementEventHandler(xs_UnknownAttribute); Each of these event handlers basically do the same thing, they print out the node name or the attribute name causing the issue. But for some reason, an InvalidOperationException is getting thrown saying there is an error in the xml document with . I thought these errors would be caught by my events?

    Read the article

  • Java Swing UI Changing Method

    - by vigilant
    I would like to use Swing to program a simple learning game. I am wondering what would be best way to switch between UI screens. For example, I would have a screen for the Main Menu, and then when the user presses a button on that screen, I would swap out the whole screen for a completely different one. Then, arbitrary screens can be swapped in at any moment, and all of their event handlers would be reactivated while the inactive screen's event handlers will be deactivated. What type of Swing component/control would I use for each of the 'screens'. Is this even doable?

    Read the article

  • How can I ensure that JavaScript inserted via AJAX will be executed after the accompanying HTML (als

    - by RenderIn
    I've got portions of pages being replaced with HTML retrieved via AJAX calls. Some of the HTML coming back has JavaScript that needs to be run once in order to initialize the accompanying HTML (setting up event handlers). Since the document has already been loaded, when I replace chunks of HTML using jQuery's .html function, having jQuery(document).ready(function() {...}); doesn't execute since the page loaded long before and this is just a snippet of HTML being replaced. What's the best way to attach event handlers whose code is packaged along with the HTML it's interested in, when that content is loaded via AJAX? Should I just put a procedural block of javascript after the HTML , so that when I insert the new HTML block, jQuery will execute the javascript immediately? Is the HTML definitely in the DOM and ready to be acted upon by JavaScript which is in the same .html call?

    Read the article

  • Programmatic binding of accelerators in wxPython

    - by Inductiveload
    I am trying to programmatically create and bind a table of accelerators in wxPython in a loop so that I don't need to worry about getting and assigning new IDs to each accelerators (and with a view to inhaling the handler list from some external resource, rather than hard-coding them). I also pass in some arguments to the handler via a lambda since a lot of my handlers will be the same but with different parameters (move, zoom, etc). The class is subclassed from wx.Frame and setup_accelerators() is called during initialisation. def setup_accelerators(self): bindings = [ (wx.ACCEL_CTRL, wx.WXK_UP, self.on_move, 'up'), (wx.ACCEL_CTRL, wx.WXK_DOWN, self.on_move, 'down'), (wx.ACCEL_CTRL, wx.WXK_LEFT, self.on_move, 'left'), (wx.ACCEL_CTRL, wx.WXK_RIGHT, self.on_move, 'right'), ] accelEntries = [] for binding in bindings: eventId = wx.NewId() accelEntries.append( (binding[0], binding[1], eventId) ) self.Bind(wx.EVT_MENU, lambda event: binding[2](event, binding[3]), id=eventId) accelTable = wx.AcceleratorTable(accelEntries) self.SetAcceleratorTable(accelTable) def on_move(self, e, direction): print direction However, this appears to bind all the accelerators to the last entry, so that Ctrl+Up prints "right", as do all the other three. How to correctly bind multiple handlers in this way?

    Read the article

  • Replacing jQuery.live() with jQuery.on()

    - by Rick Strahl
    jQuery 1.9 and 1.10 have introduced a host of changes, but for the most part these changes are mostly transparent to existing application usage of jQuery. After spending some time last week with a few of my projects and going through them with a specific eye for jQuery failures I found that for the most part there wasn't a big issue. The vast majority of code continues to run just fine with either 1.9 or 1.10 (which are supposed to be in sync but with 1.10 removing support for legacy Internet Explorer pre-9.0 versions). However, one particular change in the new versions has caused me quite a bit of update trouble, is the removal of the jQuery.live() function. This is my own fault I suppose - .live() has been deprecated for a while, but with 1.9 and later it was finally removed altogether from jQuery. In the past I had quite a bit of jQuery code that used .live() and it's one of the things that's holding back my upgrade process, although I'm slowly cleaning up my code and switching to the .on() function as the replacement. jQuery.live() jQuery.live() was introduced a long time ago to simplify handling events on matched elements that exist currently on the document and those that are are added in the future and also match the selector. jQuery uses event bubbling, special event binding, plus some magic using meta data attached to a parent level element to check and see if the original target event element matches the selected selected elements (for more info see Elijah Manor's comment below). An Example Assume a list of items like the following in HTML for example and further assume that the items in this list can be appended to at a later point. In this app there's a smallish initial list that loads to start, and as the user scrolls towards the end of the initial small list more items are loaded dynamically and added to the list.<div id="PostItemContainer" class="scrollbox"> <div class="postitem" data-id="4z6qhomm"> <div class="post-icon"></div> <div class="postitemheader"><a href="show/4z6qhomm" target="Content">1999 Buick Century For Sale!</a></div> <div class="postitemprice rightalign">$ 3,500 O.B.O.</div> <div class="smalltext leftalign">Jun. 07 @ 1:06am</div> <div class="post-byline">- Vehicles - Automobiles</div> </div> <div class="postitem" data-id="2jtvuu17"> <div class="postitemheader"><a href="show/2jtvuu17" target="Content">Toyota VAN 1987</a></div> <div class="postitemprice rightalign">$950</div> <div class="smalltext leftalign">Jun. 07 @ 12:29am</div> <div class="post-byline">- Vehicles - Automobiles</div> </div> … </div> With the jQuery.live() function you could easily select elements and hook up a click handler like this:$(".postitem").live("click", function() {...}); Simple and perfectly readable. The behavior of the .live handler generally was the same as the corresponding simple event handlers like .click(), except that you have to explicitly name the event instead of using one of the methods. Re-writing with jQuery.on() With .live() removed in 1.9 and later we have to re-write .live() code above with an alternative. The jQuery documentation points you at the .on() or .delegate() functions to update your code. jQuery.on() is a more generic event handler function, and it's what jQuery uses internally to map the high level event functions like .click(),.change() etc. that jQuery exposes. Using jQuery.on() however is not a one to one replacement of the .live() function. While .on() can handle events directly and use the same syntax as .live() did, you'll find if you simply switch out .live() with .on() that events on not-yet existing elements will not fire. IOW, the key feature of .live() is not working. You can use .on() to get the desired effect however, but you have to change the syntax to explicitly handle the event you're interested in on the container and then provide a filter selector to specify which elements you are actually interested in for handling the event for. Sounds more complicated than it is and it's easier to see with an example. For the list above hooking .postitem clicks, using jQuery.on() looks like this:$("#PostItemContainer").on("click", ".postitem", function() {...}); You specify a container that can handle the .click event and then provide a filter selector to find the child elements that trigger the  the actual event. So here #PostItemContainer contains many .postitems, whose click events I want to handle. Any container will do including document, but I tend to use the container closest to the elements I actually want to handle the events on to minimize the event bubbling that occurs to capture the event. With this code I get the same behavior as with .live() and now as new .postitem elements are added the click events are always available. Sweet. Here's the full event signature for the .on() function: .on( events [, selector ] [, data ], handler(eventObject) ) Note that the selector is optional - if you omit it you essentially create a simple event handler that handles the event directly on the selected object. The filter/child selector required if you want life-like - uh, .live() like behavior to happen. While it's a bit more verbose than what .live() did, .on() provides the same functionality by being more explicit on what your parent container for trapping events is. .on() is good Practice even for ordinary static Element Lists As a side note, it's a good practice to use jQuery.on() or jQuery.delegate() for events in most cases anyway, using this 'container event trapping' syntax. That's because rather than requiring lots of event handlers on each of the child elements (.postitem in the sample above), there's just one event handler on the container, and only when clicked does jQuery drill down to find the matching filter element and tries to match it to the originating element. In the early days of jQuery I used manually build handlers that did this and manually drilled from the event object into the originalTarget to determine if it's a matching element. With later versions of jQuery the various event functions in jQuery essentially provide this functionality out of the box with functions like .on() and .delegate(). All of this is nothing new, but I thought I'd write this up because I have on a few occasions forgotten what exactly was needed to replace the many .live() function calls that litter my code - especially older code. This will be a nice reminder next time I have a memory blank on this topic. And maybe along the way I've helped one or two of you as well to clean up your .live() code…© Rick Strahl, West Wind Technologies, 2005-2013Posted in jQuery   Tweet !function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs"); (function() { var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true; po.src = 'https://apis.google.com/js/plusone.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s); })();

    Read the article

  • ASP.NET WebAPI Security 3: Extensible Authentication Framework

    - by Your DisplayName here!
    In my last post, I described the identity architecture of ASP.NET Web API. The short version was, that Web API (beta 1) does not really have an authentication system on its own, but inherits the client security context from its host. This is fine in many situations (e.g. AJAX style callbacks with an already established logon session). But there are many cases where you don’t use the containing web application for authentication, but need to do it yourself. Examples of that would be token based authentication and clients that don’t run in the context of the web application (e.g. desktop clients / mobile). Since Web API provides a nice extensibility model, it is easy to implement whatever security framework you want on top of it. My design goals were: Easy to use. Extensible. Claims-based. ..and of course, this should always behave the same, regardless of the hosting environment. In the rest of the post I am outlining some of the bits and pieces, So you know what you are dealing with, in case you want to try the code. At the very heart… is a so called message handler. This is a Web API extensibility point that gets to see (and modify if needed) all incoming and outgoing requests. Handlers run after the conversion from host to Web API, which means that handler code deals with HttpRequestMessage and HttpResponseMessage. See Pedro’s post for more information on the processing pipeline. This handler requires a configuration object for initialization. Currently this is very simple, it contains: Settings for the various authentication and credential types Settings for claims transformation Ability to block identity inheritance from host The most important part here is the credential type support, but I will come back to that later. The logic of the message handler is simple: Look at the incoming request. If the request contains an authorization header, try to authenticate the client. If this is successful, create a claims principal and populate the usual places. If not, return a 401 status code and set the Www-Authenticate header. Look at outgoing response, if the status code is 401, set the Www-Authenticate header. Credential type support Under the covers I use the WIF security token handler infrastructure to validate credentials and to turn security tokens into claims. The idea is simple: an authorization header consists of two pieces: the schema and the actual “token”. My configuration object allows to associate a security token handler with a scheme. This way you only need to implement support for a specific credential type, and map that to the incoming scheme value. The current version supports HTTP Basic Authentication as well as SAML and SWT tokens. (I needed to do some surgery on the standard security token handlers, since WIF does not directly support string-ified tokens. The next version of .NET will fix that, and the code should become simpler then). You can e.g. use this code to hook up a username/password handler to the Basic scheme (the default scheme name for Basic Authentication). config.Handler.AddBasicAuthenticationHandler( (username, password) => username == password); You simply have to provide a password validation function which could of course point back to your existing password library or e.g. membership. The following code maps a token handler for Simple Web Tokens (SWT) to the Bearer scheme (the currently favoured scheme name for OAuth2). You simply have to specify the issuer name, realm and shared signature key: config.Handler.AddSimpleWebTokenHandler(     "Bearer",     http://identity.thinktecture.com/trust,     Constants.Realm,     "Dc9Mpi3jaaaUpBQpa/4R7XtUsa3D/ALSjTVvK8IUZbg="); For certain integration scenarios it is very useful if your Web API can consume SAML tokens. This is also easily accomplishable. The following code uses the standard WIF API to configure the usual SAMLisms like issuer, audience, service certificate and certificate validation. Both SAML 1.1 and 2.0 are supported. var registry = new ConfigurationBasedIssuerNameRegistry(); registry.AddTrustedIssuer( "d1 c5 b1 25 97 d0 36 94 65 1c e2 64 fe 48 06 01 35 f7 bd db", "ADFS"); var adfsConfig = new SecurityTokenHandlerConfiguration(); adfsConfig.AudienceRestriction.AllowedAudienceUris.Add( new Uri(Constants.Realm)); adfsConfig.IssuerNameRegistry = registry; adfsConfig.CertificateValidator = X509CertificateValidator.None; // token decryption (read from configuration section) adfsConfig.ServiceTokenResolver = FederatedAuthentication.ServiceConfiguration.CreateAggregateTokenResolver(); config.Handler.AddSaml11SecurityTokenHandler("SAML", adfsConfig); Claims Transformation After successful authentication, if configured, the standard WIF ClaimsAuthenticationManager is called to run claims transformation and validation logic. This stage is used to transform the “technical” claims from the security token into application claims. You can either have a separate transformation logic, or share on e.g. with the containing web application. That’s just a matter of configuration. Adding the authentication handler to a Web API application In the spirit of Web API this is done in code, e.g. global.asax for web hosting: protected void Application_Start() {     AreaRegistration.RegisterAllAreas();     ConfigureApis(GlobalConfiguration.Configuration);     RegisterGlobalFilters(GlobalFilters.Filters);     RegisterRoutes(RouteTable.Routes);     BundleTable.Bundles.RegisterTemplateBundles(); } private void ConfigureApis(HttpConfiguration configuration) {     configuration.MessageHandlers.Add( new AuthenticationHandler(ConfigureAuthentication())); } private AuthenticationConfiguration ConfigureAuthentication() {     var config = new AuthenticationConfiguration     {         // sample claims transformation for consultants sample, comment out to see raw claims         ClaimsAuthenticationManager = new ApiClaimsTransformer(),         // value of the www-authenticate header, // if not set, the first scheme added to the handler collection is used         DefaultAuthenticationScheme = "Basic"     };     // add token handlers - see above     return config; } You can find the full source code and some samples here. In the next post I will describe some of the samples in the download, and then move on to authorization. HTH

    Read the article

  • how this code works and how to modify this code to get my desrire work? [closed]

    - by imon_bayazid
    I dont understand how these code works here : m_MouseHookManager.MouseDoubleClick+=HookManager_MouseDoubleClick; m_MouseHookManager.MouseDoubleClick -= HookManager_MouseDoubleClick; m_KeyboardHookManager.KeyPress +=HookManager_KeyPress; m_KeyboardHookManager.KeyPress -=HookManager_KeyPress; My full Code is here : using System; using System.Windows.Forms; using MouseKeyboardActivityMonitor.WinApi; namespace MouseKeyboardActivityMonitor.Demo { public partial class TestFormHookListeners : Form { private readonly KeyboardHookListener m_KeyboardHookManager; private readonly MouseHookListener m_MouseHookManager; public TestFormHookListeners() { InitializeComponent(); m_KeyboardHookManager = new KeyboardHookListener(new GlobalHooker()); // Hooks are not active after instantiation. You need to use either Enabled property or call Start()()()() method m_KeyboardHookManager.Enabled = true;//True - The Hook is presently installed, activated, and will fire events. m_MouseHookManager = new MouseHookListener(new GlobalHooker()); m_MouseHookManager.Enabled = true; } #region Check boxes to set or remove particular event handlers. private void checkBoxMouseDoubleClick_CheckedChanged(object sender, EventArgs e) { if (checkBoxMouseDoubleClick.Checked) { m_MouseHookManager.MouseDoubleClick += HookManager_MouseDoubleClick; } else { m_MouseHookManager.MouseDoubleClick -= HookManager_MouseDoubleClick; } } private void checkBoxKeyPress_CheckedChanged(object sender, EventArgs e) { if (checkBoxKeyPress.Checked) { m_KeyboardHookManager.KeyPress +=HookManager_KeyPress; } else { m_KeyboardHookManager.KeyPress -=HookManager_KeyPress; } } #endregion #region Event handlers of particular events. They will be activated when an appropriate checkbox is checked. private void HookManager_KeyPress(object sender, KeyPressEventArgs e) { Log(string.Format("KeyPress \t\t {0}\n", e.KeyChar)); } private void HookManager_MouseDoubleClick(object sender, MouseEventArgs e) { Log(string.Format("MouseDoubleClick \t\t {0}\n", e.Button)); } private void Log(string text) { textBoxLog.AppendText(text); textBoxLog.ScrollToCaret(); } #endregion private void checkBoxEnabled_CheckedChanged(object sender, EventArgs e) { m_MouseHookManager.Enabled = checkBoxEnabled.Checked; m_KeyboardHookManager.Enabled = checkBoxEnabled.Checked; } private void radioHooksType_CheckedChanged(object sender, EventArgs e) { Hooker hook; if (radioApplication.Checked) { hook = new AppHooker();//Provides methods for subscription and unsubscription to application mouse and keyboard hooks. } else { hook = new GlobalHooker();//Provides methods for subscription and unsubscription to global mouse and keyboard hooks. } m_KeyboardHookManager.Replace(hook); m_MouseHookManager.Replace(hook);//hook->An AppHooker or GlobalHooker object. //Enables you to switch from application hooks to global hooks //and vice versa on the fly without unsubscribing from events. //Component remains enabled or disabled state after this call as it was before. //Declaration Syntax } private void HookManager_Supress(object sender, MouseEventExtArgs e) { if (e.Button != MouseButtons.Right) { return; } Log("Suppressed.\n"); e.Handled = true; } } } Can anybody help to understand that??? I want by this that whenever a F5 key-pressed my application will be active and then it checks if double-click happen it gives a message .... **How can i modify that.....??????**

    Read the article

  • interview for an embedded systems C developer profile

    - by Registered User
    Following are interview questions 1) code for kernel scheduler ( I could not, he said even if some portion of code then fine I have read but reproducing them I could not do that ) 2) asked to write code for Interrupt handlers (I am aware but could not reproduce code ) 3)Device drivers file operations (this I was able to write) 4) Asked to explain Xen bootstrapping and architecture code (not diagrams) I am looking for links where code has been explained.I have read such things but I some times feel difficult to understand without having a proper explanation. So in case you are aware of any such things let me know.

    Read the article

  • jQuery - how to check/uncheck a checkbox

    - by Renso
    $('#PrimaryContacts').unbind().change(function() {         if ($('#PrimaryContacts option:selected').val() == 0) {             $('#filterPrimaryContact').removeAttr('checked').trigger('click');         }         else {             $('#filterPrimaryContact').trigger('click');         }     }); Also, in the example above, triggering the checkbox does not change the checkbox value. As depicted above, based on a dropdown box changing and no contact being selected from the drop down box, automatically uncheck the checkbox and trigger it in invoke any event handlers on the checkbox.

    Read the article

  • Development Approach: User Interface In or Domain Model Out?

    - by Berin Loritsch
    While I've never delivered anything using Smalltalk, my brief time playing with it has definitely left its mark. The only way to describe the experience is MVC the way it was meant to be. Essentially, all the heavy lifting for your application is done in the business objects (or domain model if you are so inclined). The standard controls are bound to the business objects in some way. For example, a text box is mapped to an object's field (the field itself is an object so it's easy to do). A button would mapped to a method. This is all done with a very simple and natural API. We don't have to think about binding objects, etc. It just works. Yet, in many newer languages and APIs you are forced to think from the outside in. First with C++ and MFC, and now with C# and WPF, Microsoft has gotten it's developer world hooked on GUI builders where you build your application by implementing event handlers. Java Swing development isn't so different, only you are writing the code to instantiate the controls on the form yourself. For some projects, there may never even be a domain model--just event handlers. I've been in and around this model for most of my carreer. Each way forces you to think differently. With the Smalltalk approach, your domain is smart while your GUI is dumb. With the default VisualStudio approach, your GUI is smart while your domain model (if it exists) is rather anemic. Many developers that I work with see value in the Smalltalk approach, and try to shoehorn that approach into the VisualStudio environment. WPF has some dynamic binding features that makes it possible; but there are limitations. Inevitably some code that belongs in the domain model ends up in the GUI classes. So, which way do you design/develop your code? Why? GUI first. User interaction is paramount. Domain first. I need to make sure the system is correct before we put a UI on it. There's pros and cons for either approach. Domain model fits in there with crystal cathedrals and pie in the sky. GUI fits in there with quick and dirty (sometimes really dirty). And for an added bonus: How do you make sure the code is maintainable?

    Read the article

< Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >