Search Results

Search found 3984 results on 160 pages for 'david gray wright'.

Page 138/160 | < Previous Page | 134 135 136 137 138 139 140 141 142 143 144 145  | Next Page >

  • Why is the binding icon not visible in blend?

    - by Ankit Rathod
    Hello, Why is the binding icon (a small gray icon) not visible in blend for some properties even though they are DependencyProperties? For eg. I dragged a button on my page and dragged a textbox. I want to bind button's content property to textbox's text property. But i can't find the Binding icon in Blend. I know if i type the binding syntax in code it will work just fine. But why is that icon missing? Thanks in advance :)

    Read the article

  • HOw to Extract image pixels and perform computation on it

    - by gavishna
    What i want to do is extract the pixels into array A(i,j).Let A(i,j) represent the pixel in the ith row & jth colm of the image. Let B(i,j) be the transformed array containing bits such that B(i,j) = 1 if (A(i,j)/2^t) mod 2 =1, where t=0,1,2,3,4,5,6,7 = 0 otherwise Then the array B(i,j) will be mutliplied by another array say C(i,j) representing another image. Then i want to plot the result of B*C as an image. How do i take in the pixels for the above conditions for both gray and RGB color format.Also how do i solve the above problem.Any helo will be usefull because i am not an expert in image processing.

    Read the article

  • How can I get .NET/Silverlight source code symbols to work in VS 2010?

    - by mattx
    Back when M$ first released the ability to point visual studio at a symbol server and actually debug into .NET code I got it up and working no problem on VS2008. Now trying to do this with VS2010 or my local copy of VS2008 doesn't seem to work. It successfully downloads the symbols and the stack frames turn from gray to black but there is no source available. Has anyone gotten this working? If so what's the secret? Also is there source available for Silverlight included?

    Read the article

  • Should I use a config file or database for storing business rules?

    - by foiseworth
    I have recently been reading The Pragmatic Programmer which states that: Details mess up our pristine code—especially if they change frequently. Every time we have to go in and change the code to accommodate some change in business logic, or in the law, or in management's personal tastes of the day, we run the risk of breaking the system—of introducing a new bug. Hunt, Andrew; Thomas, David (1999-10-20). The Pragmatic Programmer: From Journeyman to Master (Kindle Locations 2651-2653). Pearson Education (USA). Kindle Edition. I am currently programming a web app that has some models that have properties that can only be from a set of values, e.g. (not actual example as the web app data confidential): light-type = sphere / cube / cylinder The light type can only be the above three values but according to TPP I should always code as if they could change and place their values in a config file. As there are several incidents of this throughout the app, my question is: Should I store possibly values like these in: a config file: 'light-types' = array(sphere, cube, cylinder), 'other-type' = value, 'etc = etc-value a single table in a database with one line for each config item a database with a table for each config item (e.g. table: light_types; columns: id, name) some other way? Many thanks for any assistance / expertise offered.

    Read the article

  • MapView tiles loading in Android

    - by Pich
    In the Maps application (at least version 5) for Android the tiles are loading in a different way, than when using a MapView in my own application, when for example zooming in or out. In the MapView displays a gray checkered image until the tile is fully loaded an than the map is displayed. In Maps application this it not the case all the time. Tiles that are not fully loaded are still showing a map but it is blurry. The Maps application way of showing the map when zooming is much prettier for the eye. Is it possible to have this "feature" in a MapView in my own application as well? Best regards P

    Read the article

  • Fixed positioned div with a fixed height and relative or absolute divs inside it with greater height

    - by emilolsson
    Hello I have a problem with IE. I have a fixed div like this: #fixed { position: fixed; top: 0px; left: 0px; z-index: 9998; width: 100%; height: 40px; } Inside this div I want to place another div that has a height that is higher than its holder (higher than 40px). So I put a relative or an absolute div inside it and it works splendid in all browsers except IE, at least IE8. But in IE8 the child div gets cut because of the height of 40px specified for it's holder. Is there any workaround to this problem? I'm starting to get gray hairs..

    Read the article

  • Firebug is permanently inactive

    - by bwb
    Firebug used to work fine -- until something happened -- not sure what. FF 3.6.3 on XP PRo current. The net effect is Firebug is now always inactive. The icon is present and gray as is normal. Click on the icon and I get: It does this regardless of the site. I've uninstalled Firebug and re-installed. nada. Additionally, the Tools Firebug menu yields nothing. The only unusual issue I can think of is it may of stopped working sometime after I created an additional FF profile (which has since been removed) for a test. Somehow, in removing the extra profile, my bookmarks were deleted. I recovered them from by my online-backup service. Any suggestions? I'd really like to get the Firebug functionality back. thanks.

    Read the article

  • Creating ActionEvent object for CustomButton in Java

    - by Crystal
    For a hw assignment, we were supposed to create a custom button to get familiar with swing and responding to events. We were also to make this button an event source which confuses me. I have an ArrayList to keep track of listeners that would register to listen to my CustomButton. What I am getting confused on is how to notify the listeners. My teacher hinted at having a notify and overriding actionPerformed which I tried doing, but then I wasn't sure how to create an ActionEvent object looking at the constructor documentation. The source, id, string all confuses me. Any help would be appreciated. Thanks! code: import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.util.List; import java.util.ArrayList; public class CustomButton { public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { CustomButtonFrame frame = new CustomButtonFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } }); } public void addActionListener(ActionListener al) { listenerList.add(al); } public void removeActionListener(ActionListener al) { listenerList.remove(al); } public void actionPerformed(ActionEvent e) { System.out.println("Button Clicked!"); } private void notifyListeners() { ActionEvent event = new ActionEvent(CONFUSED HERE!!!!; for (ActionListener action : listenerList) { action.actionPerfomed(event); } } List<ActionListener> listenerList = new ArrayList<ActionListener>(); } class CustomButtonFrame extends JFrame { // constructor for CustomButtonFrame public CustomButtonFrame() { setTitle("Custom Button"); CustomButtonSetup buttonSetup = new CustomButtonSetup(); this.add(buttonSetup); this.pack(); } } class CustomButtonSetup extends JComponent { public CustomButtonSetup() { ButtonAction buttonClicked = new ButtonAction(); this.addMouseListener(buttonClicked); } // because frame includes borders and insets, use this method public Dimension getPreferredSize() { return new Dimension(200, 200); } public void paintComponent(Graphics g) { Graphics2D g2 = (Graphics2D) g; // first triangle coords int x[] = new int[TRIANGLE_SIDES]; int y[] = new int[TRIANGLE_SIDES]; x[0] = 0; y[0] = 0; x[1] = 200; y[1] = 0; x[2] = 0; y[2] = 200; Polygon firstTriangle = new Polygon(x, y, TRIANGLE_SIDES); // second triangle coords x[0] = 0; y[0] = 200; x[1] = 200; y[1] = 200; x[2] = 200; y[2] = 0; Polygon secondTriangle = new Polygon(x, y, TRIANGLE_SIDES); g2.drawPolygon(firstTriangle); g2.setColor(firstColor); g2.fillPolygon(firstTriangle); g2.drawPolygon(secondTriangle); g2.setColor(secondColor); g2.fillPolygon(secondTriangle); // draw rectangle 10 pixels off border int s1[] = new int[RECT_SIDES]; int s2[] = new int[RECT_SIDES]; s1[0] = 5; s2[0] = 5; s1[1] = 195; s2[1] = 5; s1[2] = 195; s2[2] = 195; s1[3] = 5; s2[3] = 195; Polygon rectangle = new Polygon(s1, s2, RECT_SIDES); g2.drawPolygon(rectangle); g2.setColor(thirdColor); g2.fillPolygon(rectangle); } private class ButtonAction implements MouseListener { public void mousePressed(MouseEvent e) { System.out.println("Click!"); firstColor = Color.GRAY; secondColor = Color.WHITE; repaint(); } public void mouseReleased(MouseEvent e) { System.out.println("Released!"); firstColor = Color.WHITE; secondColor = Color.GRAY; repaint(); } public void mouseEntered(MouseEvent e) {} public void mouseExited(MouseEvent e) {} public void mouseClicked(MouseEvent e) {} } public static final int TRIANGLE_SIDES = 3; public static final int RECT_SIDES = 4; private Color firstColor = Color.WHITE; private Color secondColor = Color.DARK_GRAY; private Color thirdColor = Color.LIGHT_GRAY; }

    Read the article

  • Why does the android emulator camera stop unexpectedly?

    - by user490074
    I am using Android 2.2 (API Level 8). The camera is enabled in the manifest. When I try the camera icon provided by the emulator model, it runs for a few seconds showing a gray box moving around a black and white checkerboard, then dies with the error message: Sorry! The application Camera (process com.android.camera) has stopped unexpectedly. Please try again. Trying again, of course, doesn't help. I am using the provided emulator camera to compare behavior with a camera application I am working on. Why does the android emulator camera stop unexpectedly?

    Read the article

  • Oracle Buys BigMachines - Adds Leading Configure, Price and Quote (CPQ) Cloud to the Oracle Cloud to Enable Smarter Selling

    - by Richard Lefebvre
    News Facts Oracle today announced that it has entered into an agreement to acquire BigMachines, a leading cloud-based Configure, Price and Quote (CPQ) solution provider. BigMachines’ CPQ Cloud accelerates the conversion of sales opportunities into revenue by automating the sales order process with guided selling, dynamic pricing, and an easy-to-use workflow approval process, accessible anywhere, on any device. Companies that use sales automation technology often rely on manual, cumbersome and disconnected processes to convert opportunities into orders. This creates errors, adds costs, delays revenue, and degrades the customer experience. BigMachines’ CPQ cloud extends sales automation to include the creation of an optimal quote, which enables sales personnel to easily configure and price complex products, select the best options, promotions and deal terms, and include up sell and renewals, all using automated workflows. In combination with Oracle’s enterprise-grade cloud solutions, including Marketing, Sales, Social, Commerce and Service Clouds, Oracle and BigMachines will create an end-to-end smarter selling cloud solution so sales personnel are more productive, customers are more satisfied, and companies grow revenue faster. More information on this announcement can be found at http://www.oracle.com/bigmachines Supporting Quotes “The fundamental goals of smarter selling are to provide sales teams with the information, access, and insights they need to maximize revenue opportunities and execute on all phases of the sales cycle,” said Thomas Kurian, Executive Vice President, Oracle Development. “By adding BigMachines’ CPQ Cloud to the Oracle Cloud, companies will be able to drive more revenue and increase customer satisfaction with a seamlessly integrated process across marketing and sales, pricing and quoting, and fulfillment and service.” “BigMachines has developed leading CPQ solutions that serve companies of all sizes across multiple industries,” said David Bonnette, BigMachines’ CEO. “Together with Oracle, we expect to provide a complete cloud solution to manage sales processes and deliver exceptional customer experiences.” Supporting Resources About Oracle and BigMachines General Presentation Customer and Partner Letter FAQ

    Read the article

  • margin-bottom property of a div's last element doesn't "extend" the div

    - by kitsched
    I have an element in a div, which has a background image. Below the div I have another div with another background image. Now the problem is that if the last element contained in the first div has margin-bottom applied there will be a gap between the 2 divs like this: Notice the gray gap caused by the margin-bottom property of the h2 element contained within the first div. I know this can be solved if I switch margin-bottom to padding-bottom but what if I need margin-bottom? How to fix this?

    Read the article

  • A depth (z-index) nightmare.

    - by JCOC611
    The best way to illustrate this question is with...a Fiddle! Before you visit the fiddle, notice there is text behind the grayest element, which is on top of a light gray element that has a border. There is a main wrapping div (root), and two wrapping divs inside (wrap1 and wrap2). The problem here is that I need the content of wrap2 (highlight) to be behind the content of wrap1 (text), but in front of the background of the root. This, however, must not change: The HTML, the elements and wraps should be left untouched. Excluding the order of wrap1 and wrap2 inside root. The highlight div must keep the absolute positioning. Styling highlight with background-color is not an option, the existence of highlight is a must. PS: the italics reference the id's of <div>s in the fiddle example, for whomever was too lazy to visit it.

    Read the article

  • UITextField placeholder looks strange when UITableViewCellSelectionStyleGray

    - by mongeta
    Hello, I've set the background color of my UITableViewCells to Gray. But if there's a UITextField in the cell, the placeholder doesn't change their color to white/black and it's almost impossible to read it, and look stranges. The UILabel from the cell changes their color when it's selected or not, but the placeholder remains always the same. There's a simple solution ? I don't want to add some UILabel and use it as a placeholder, etc. etc. Thanks, r.

    Read the article

  • Different Rendering of SimpleModal on IE7 and Chrome

    - by Silver Gun
    Hey Guys I tried out Simple Modal for my modal dialog needs. The jQuery $(function() { $('#showDialog').click(function() { $('<div><p> Click Here! </p></div>').modal({ overlayClose: true, opacity: 30 }) }); }); The CSS was as follows: #simplemodal-overlay { background-color: #000; } #simplemodal-container { background-color: #333; border: 8px solid #444; padding: 12px; } In IE6 and 7, it displays a nice, very transparent, gray overlay with a dark small box in the middle with the text 'Click Here!'. But in CHROME (4.0.249.43) I get a dark black overlay with 100% opacity. Any ideas? Thanks in advance

    Read the article

  • iPhone - In App Purchase questions

    - by diwup
    Hey guys, Merry Christmas. I have two questions on In App Purchase. iAP application process: do I need to submit my iAP items applications, wait for Apple's responses, then build my app accordingly, or, I can just create some iAP items, build them into my app, then after everything's done, submit my binary to Apple? Intermediary currency: on Apple's documentation I found these sentences: "You may not offer items that represent intermediary currency because it is important that users know the specific good or service that they are buying." However, I found a few apps on the App Store offering its users with different kinds of intermediary currency. I'm confused. Is this a gray area in which we developers can play some tricks? Thanks in advance. Di

    Read the article

  • how should i load a bitmap for an android game?

    - by Heysus Escobar
    i been working on a game with no bitmaps or anything, I'm using rectangles as objects and changing their color for their purpose like a red rectangles for player and gray rectangles for walls. My question is what is the right way to replace the rectangles with bitmaps/images? I know to load Bitmaps you can just do this : Bitmap randomBitmap = BitmapFactory.decodeResource(getResources(), com.example.android4gametest.R.drawable.ic_launcher); Should i load all my Bitmaps and pass them to their Classes or should i load the bitmap inside their class instead of passing it ? and how would i do that because i cannot use the BitmapFactory because i have no access to the getResources()! or should i load my bitmaps/images from my assets folder which i know i wont have the same "tools" you can say to mess with the bitmap.

    Read the article

  • Popup control from dll in web page

    - by Argons
    I'm developing a kind of framework that will work in web and win, so I have this interface: public interface IViewsManager { ... void ShowMessage(); ... } And I have the implementation for win that call a popup control from another dll. My problem is when I try to implement it for web enviroment, I have to call a popup control from another dll, and I would like to show the popup and the web page disables with a gray layer, and I don't know how to do it. Please, any help will be appreciated. Thanks in advance.

    Read the article

  • WPF Databinding and Styling based on Data in an item in an IList

    - by Nate Bross
    I have a ListBox bound to a list of Items (for arguement, lets say its got a string and two dates Entered and Done). I would like to make the background color of items in the ListBox have a gray color if the Done DateTime is != DateTime.MinValue. Edit: Should I make a converter? and convert DateTime to a Brush based on the value of the DateTime? Is something like this my best option? or is there a simple Xaml snippet I could use? [ValueConversion(typeof(DateTime), typeof(Brush))] class MyConverter : IValueConverter { ... }

    Read the article

  • How to compute power spectrum from 2D FFT

    - by user1452954
    I've encounter a problem when doing my lab assignment, not sure how to implement this: Use fft2 on a gray image and to do Fourier transform and then compute the power spectrum. This is my code so far: >> Pc = imread('pckint.jpg'); >> whos Pc; Name Size Bytes Class Attributes Pc 256x256 65536 uint8 >> imshow(Pc); >> result = fft2(Pc); My question is from the result. How to computer power spectrum?

    Read the article

  • how to split this label to get the specific value(free gold)

    - by Wolf
    Hello all i am having a fun filled irritating little problem which i am sure can be resolved in less than 5 seconds with the enlightened and combined minds of stack overflow users ok first off it seems i am having trouble communicating what my trouble is with the gentlemen and ladies who are trying to help me in earlier posts so i am going to make it very simple i need to get 337 and 229 out of this son of satan string that is constantly updating every 2 seconds now i dont know how to go about doing this i know i should probably use split but i dont know how to do it on this because i have very little experience with it Last login: Thu Jun 5 08:20:35 2014 from .** /*/*-..****.**///*-****.**.*/****/*/***status Virtual server [...] is UP. *: 337 bananas left ****(s)******: 229 bananas eaten(s) ** *. [* ] – i am tired and would like to finish this before i am gray or sentanced to prison for raving naked down my street please help and thanks in advance p.s dont really care if this gets down voted a bit tired and more than a little angry so enjoy

    Read the article

  • Make the text of a disabled textbox easier to see

    - by Vaccano
    I have a text box that when it is disabled the text in it is gray and kind of dithered. (This is the standard functionality.) Is there a way to make this easier to see? I have tried this: txtBoxNumber.Enabled = false; txtBoxNumber.ForeColor = Color.Black; and that has no effect. NOTE: This is a .net Compact Framework app, but I am not tagging the question with CF because I think it is the same for normal .net.

    Read the article

  • Cannot select elements with jquery after a html() load in Internet Explorer 8. Mozilla works fine...

    - by user641379
    I have the following code that runs in a display:none; divtab1 function ToggleTab(tab_id) { $('.divtab1').html('<div class="promo2">Testing</div>...more'); $('.promo2').css("border", "1px solid gray"); } html document: <a href="javascript:ToggleTab(1);">try</a> <div class="divtab"></div> It works fine in Mozilla but not in IE. The actual data come from an ajax request but nothing can be selected in IE! Thanks a lot

    Read the article

  • Why is the camera not following the player? [on hold]

    - by Homer_Simpson
    I use the following code to create Parallax Scrolling: http://www.david-gouveia.com/portfolio/2d-camera-with-parallax-scrolling-in-xna/ Parallax Scrolling is working but I don't know how to focus the camera on the player. If the player moves, then the camera doesn't follow the player. The player leaves the screen when I'm moving it. I use the following code(as described in the tutorial), but it's not working: // Updates my camera to lock on the character _camera.LookAt(player.Playerposition); What can I do so that the player is always in the center of the screen/camera? My player class: public class Player { Texture2D Playertex; public Vector2 Playerposition = new Vector2(400, 240); private Game1 game1; public Player(Game1 game) { game1 = game; } public void Load(ContentManager content) { Playertex = content.Load<Texture2D>("8bitmario"); TouchPanel.EnabledGestures = GestureType.HorizontalDrag; } public void Update(GameTime gameTime) { while (TouchPanel.IsGestureAvailable) { GestureSample gs = TouchPanel.ReadGesture(); switch (gs.GestureType) { case GestureType.HorizontalDrag: Playerposition.X += 3f; break; } } } public void Render(SpriteBatch batch) { batch.Draw(Playertex, new Vector2(Playerposition.X - Playertex.Width / 2, Playerposition.Y - Playertex.Height / 2), Color.White); } } In Game1, I update the player and camera class: protected override void Update(GameTime gameTime) { // Updates my character's position player.Update(gameTime); // Updates my camera to lock on the character _camera.LookAt(player.Playerposition); base.Update(gameTime); } protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.CornflowerBlue); foreach (Layer layer in _layers) layer.Draw(spriteBatch); spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, null, _camera.GetViewMatrix(new Vector2(0.0f, 0.0f))); player.Render(spriteBatch); spriteBatch.End(); base.Draw(gameTime); }

    Read the article

  • Android drawrRect only produces squares

    - by user1905553
    I present the following code snippet: // < Android / Eclipse Kepler > // < Screen resolution: 480x800 > Graphics g = game.getGraphics(); g.drawRect(0, 0, g.getWidth()/2, g.getHeight(), Color.GRAY); Produces a square [0,0], [240, 240] (240 = g.getWidth/2 = 480/2) I expected to get a rectangle [0,0] [240, 800] Can anyone tell me if I'm wrong or if the drawRect uses width instead of height? How do I fix this? Please, if possible, test before post your answer. Help me to save a ridiculous bitmap. Thanks to all!

    Read the article

  • Where does ASP.NET Web API Fit?

    - by Rick Strahl
    With the pending release of ASP.NET MVC 4 and the new ASP.NET Web API, there has been a lot of discussion of where the new Web API technology fits in the ASP.NET Web stack. There are a lot of choices to build HTTP based applications available now on the stack - we've come a long way from when WebForms and Http Handlers/Modules where the only real options. Today we have WebForms, MVC, ASP.NET Web Pages, ASP.NET AJAX, WCF REST and now Web API as well as the core ASP.NET runtime to choose to build HTTP content with. Web API definitely squarely addresses the 'API' aspect - building consumable services - rather than HTML content, but even to that end there are a lot of choices you have today. So where does Web API fit, and when doesn't it? But before we get into that discussion, let's talk about what a Web API is and why we should care. What's a Web API? HTTP 'APIs' (Microsoft's new terminology for a service I guess)  are becoming increasingly more important with the rise of the many devices in use today. Most mobile devices like phones and tablets run Apps that are using data retrieved from the Web over HTTP. Desktop applications are also moving in this direction with more and more online content and synching moving into even traditional desktop applications. The pending Windows 8 release promises an app like platform for both the desktop and other devices, that also emphasizes consuming data from the Cloud. Likewise many Web browser hosted applications these days are relying on rich client functionality to create and manipulate the browser user interface, using AJAX rather than server generated HTML data to load up the user interface with data. These mobile or rich Web applications use their HTTP connection to return data rather than HTML markup in the form of JSON or XML typically. But an API can also serve other kinds of data, like images or other binary files, or even text data and HTML (although that's less common). A Web API is what feeds rich applications with data. ASP.NET Web API aims to service this particular segment of Web development by providing easy semantics to route and handle incoming requests and an easy to use platform to serve HTTP data in just about any content format you choose to create and serve from the server. But .NET already has various HTTP Platforms The .NET stack already includes a number of technologies that provide the ability to create HTTP service back ends, and it has done so since the very beginnings of the .NET platform. From raw HTTP Handlers and Modules in the core ASP.NET runtime, to high level platforms like ASP.NET MVC, Web Forms, ASP.NET AJAX and the WCF REST engine (which technically is not ASP.NET, but can integrate with it), you've always been able to handle just about any kind of HTTP request and response with ASP.NET. The beauty of the raw ASP.NET platform is that it provides you everything you need to build just about any type of HTTP application you can dream up from low level APIs/custom engines to high level HTML generation engine. ASP.NET as a core platform clearly has stood the test of time 10+ years later and all other frameworks like Web API are built on top of this ASP.NET core. However, although it's possible to create Web APIs / Services using any of the existing out of box .NET technologies, none of them have been a really nice fit for building arbitrary HTTP based APIs. Sure, you can use an HttpHandler to create just about anything, but you have to build a lot of plumbing to build something more complex like a comprehensive API that serves a variety of requests, handles multiple output formats and can easily pass data up to the server in a variety of ways. Likewise you can use ASP.NET MVC to handle routing and creating content in various formats fairly easily, but it doesn't provide a great way to automatically negotiate content types and serve various content formats directly (it's possible to do with some plumbing code of your own but not built in). Prior to Web API, Microsoft's main push for HTTP services has been WCF REST, which was always an awkward technology that had a severe personality conflict, not being clear on whether it wanted to be part of WCF or purely a separate technology. In the end it didn't do either WCF compatibility or WCF agnostic pure HTTP operation very well, which made for a very developer-unfriendly environment. Personally I didn't like any of the implementations at the time, so much so that I ended up building my own HTTP service engine (as part of the West Wind Web Toolkit), as have a few other third party tools that provided much better integration and ease of use. With the release of Web API for the first time I feel that I can finally use the tools in the box and not have to worry about creating and maintaining my own toolkit as Web API addresses just about all the features I implemented on my own and much more. ASP.NET Web API provides a better HTTP Experience ASP.NET Web API differentiates itself from the previous Microsoft in-box HTTP service solutions in that it was built from the ground up around the HTTP protocol and its messaging semantics. Unlike WCF REST or ASP.NET AJAX with ASMX, it’s a brand new platform rather than bolted on technology that is supposed to work in the context of an existing framework. The strength of the new ASP.NET Web API is that it combines the best features of the platforms that came before it, to provide a comprehensive and very usable HTTP platform. Because it's based on ASP.NET and borrows a lot of concepts from ASP.NET MVC, Web API should be immediately familiar and comfortable to most ASP.NET developers. Here are some of the features that Web API provides that I like: Strong Support for URL Routing to produce clean URLs using familiar MVC style routing semantics Content Negotiation based on Accept headers for request and response serialization Support for a host of supported output formats including JSON, XML, ATOM Strong default support for REST semantics but they are optional Easily extensible Formatter support to add new input/output types Deep support for more advanced HTTP features via HttpResponseMessage and HttpRequestMessage classes and strongly typed Enums to describe many HTTP operations Convention based design that drives you into doing the right thing for HTTP Services Very extensible, based on MVC like extensibility model of Formatters and Filters Self-hostable in non-Web applications  Testable using testing concepts similar to MVC Web API is meant to handle any kind of HTTP input and produce output and status codes using the full spectrum of HTTP functionality available in a straight forward and flexible manner. Looking at the list above you can see that a lot of functionality is very similar to ASP.NET MVC, so many ASP.NET developers should feel quite comfortable with the concepts of Web API. The Routing and core infrastructure of Web API are very similar to how MVC works providing many of the benefits of MVC, but with focus on HTTP access and manipulation in Controller methods rather than HTML generation in MVC. There’s much improved support for content negotiation based on HTTP Accept headers with the framework capable of detecting automatically what content the client is sending and requesting and serving the appropriate data format in return. This seems like such a little and obvious thing, but it's really important. Today's service backends often are used by multiple clients/applications and being able to choose the right data format for what fits best for the client is very important. While previous solutions were able to accomplish this using a variety of mixed features of WCF and ASP.NET, Web API combines all this functionality into a single robust server side HTTP framework that intrinsically understands the HTTP semantics and subtly drives you in the right direction for most operations. And when you need to customize or do something that is not built in, there are lots of hooks and overrides for most behaviors, and even many low level hook points that allow you to plug in custom functionality with relatively little effort. No Brainers for Web API There are a few scenarios that are a slam dunk for Web API. If your primary focus of an application or even a part of an application is some sort of API then Web API makes great sense. HTTP ServicesIf you're building a comprehensive HTTP API that is to be consumed over the Web, Web API is a perfect fit. You can isolate the logic in Web API and build your application as a service breaking out the logic into controllers as needed. Because the primary interface is the service there's no confusion of what should go where (MVC or API). Perfect fit. Primary AJAX BackendsIf you're building rich client Web applications that are relying heavily on AJAX callbacks to serve its data, Web API is also a slam dunk. Again because much if not most of the business logic will probably end up in your Web API service logic, there's no confusion over where logic should go and there's no duplication. In Single Page Applications (SPA), typically there's very little HTML based logic served other than bringing up a shell UI and then filling the data from the server with AJAX which means the business logic required for data retrieval and data acceptance and validation too lives in the Web API. Perfect fit. Generic HTTP EndpointsAnother good fit are generic HTTP endpoints that to serve data or handle 'utility' type functionality in typical Web applications. If you need to implement an image server, or an upload handler in the past I'd implement that as an HTTP handler. With Web API you now have a well defined place where you can implement these types of generic 'services' in a location that can easily add endpoints (via Controller methods) or separated out as more full featured APIs. Granted this could be done with MVC as well, but Web API seems a clearer and more well defined place to store generic application services. This is one thing I used to do a lot of in my own libraries and Web API addresses this nicely. Great fit. Mixed HTML and AJAX Applications: Not a clear Choice  For all the commonality that Web API and MVC share they are fundamentally different platforms that are independent of each other. A lot of people have asked when does it make sense to use MVC vs. Web API when you're dealing with typical Web application that creates HTML and also uses AJAX functionality for rich functionality. While it's easy to say that all 'service'/AJAX logic should go into a Web API and all HTML related generation into MVC, that can often result in a lot of code duplication. Also MVC supports JSON and XML result data fairly easily as well so there's some confusion where that 'trigger point' is of when you should switch to Web API vs. just implementing functionality as part of MVC controllers. Ultimately there's a tradeoff between isolation of functionality and duplication. A good rule of thumb I think works is that if a large chunk of the application's functionality serves data Web API is a good choice, but if you have a couple of small AJAX requests to serve data to a grid or autocomplete box it'd be overkill to separate out that logic into a separate Web API controller. Web API does add overhead to your application (it's yet another framework that sits on top of core ASP.NET) so it should be worth it .Keep in mind that MVC can generate HTML and JSON/XML and just about any other content easily and that functionality is not going away, so just because you Web API is there it doesn't mean you have to use it. Web API is not a full replacement for MVC obviously either since there's not the same level of support to feed HTML from Web API controllers (although you can host a RazorEngine easily enough if you really want to go that route) so if you're HTML is part of your API or application in general MVC is still a better choice either alone or in combination with Web API. I suspect (and hope) that in the future Web API's functionality will merge even closer with MVC so that you might even be able to mix functionality of both into single Controllers so that you don't have to make any trade offs, but at the moment that's not the case. Some Issues To think about Web API is similar to MVC but not the Same Although Web API looks a lot like MVC it's not the same and some common functionality of MVC behaves differently in Web API. For example, the way single POST variables are handled is different than MVC and doesn't lend itself particularly well to some AJAX scenarios with POST data. Code Duplication I already touched on this in the Mixed HTML and Web API section, but if you build an MVC application that also exposes a Web API it's quite likely that you end up duplicating a bunch of code and - potentially - infrastructure. You may have to create authentication logic both for an HTML application and for the Web API which might need something different altogether. More often than not though the same logic is used, and there's no easy way to share. If you implement an MVC ActionFilter and you want that same functionality in your Web API you'll end up creating the filter twice. AJAX Data or AJAX HTML On a recent post's comments, David made some really good points regarding the commonality of MVC and Web API's and its place. One comment that caught my eye was a little more generic, regarding data services vs. HTML services. David says: I see a lot of merit in the combination of Knockout.js, client side templates and view models, calling Web API for a responsive UI, but sometimes late at night that still leaves me wondering why I would no longer be using some of the nice tooling and features that have evolved in MVC ;-) You know what - I can totally relate to that. On the last Web based mobile app I worked on, we decided to serve HTML partials to the client via AJAX for many (but not all!) things, rather than sending down raw data to inject into the DOM on the client via templating or direct manipulation. While there are definitely more bytes on the wire, with this, the overhead ended up being actually fairly small if you keep the 'data' requests small and atomic. Performance was often made up by the lack of client side rendering of HTML. Server rendered HTML for AJAX templating gives so much better infrastructure support without having to screw around with 20 mismatched client libraries. Especially with MVC and partials it's pretty easy to break out your HTML logic into very small, atomic chunks, so it's actually easy to create small rendering islands that can be used via composition on the server, or via AJAX calls to small, tight partials that return HTML to the client. Although this is often frowned upon as to 'heavy', it worked really well in terms of developer effort as well as providing surprisingly good performance on devices. There's still plenty of jQuery and AJAX logic happening on the client but it's more manageable in small doses rather than trying to do the entire UI composition with JavaScript and/or 'not-quite-there-yet' template engines that are very difficult to debug. This is not an issue directly related to Web API of course, but something to think about especially for AJAX or SPA style applications. Summary Web API is a great new addition to the ASP.NET platform and it addresses a serious need for consolidation of a lot of half-baked HTTP service API technologies that came before it. Web API feels 'right', and hits the right combination of usability and flexibility at least for me and it's a good fit for true API scenarios. However, just because a new platform is available it doesn't meant that other tools or tech that came before it should be discarded or even upgraded to the new platform. There's nothing wrong with continuing to use MVC controller methods to handle API tasks if that's what your app is running now - there's very little to be gained by upgrading to Web API just because. But going forward Web API clearly is the way to go, when building HTTP data interfaces and it's good to see that Microsoft got this one right - it was sorely needed! Resources ASP.NET Web API AspConf Ask the Experts Session (first 5 minutes) © Rick Strahl, West Wind Technologies, 2005-2012Posted in Web Api   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

< Previous Page | 134 135 136 137 138 139 140 141 142 143 144 145  | Next Page >